[Rust Server] Fix server example on non-Linux (#7399)

* [Rust Server] Fix server example on non-Linux

The server example is broken because it tries to import `use openssl::ssl::SslAcceptorBuilder;` unconditionally when it won't be present on MacOS, Windows or iOS and then conditionally provides `create` causing compile errors on the aforementioned platforms.

To fix, we simply move the condition from the function to the import and all is happy again :)

* Update Samples

Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
Matthew Dowdell
2020-10-05 21:54:50 +01:00
committed by GitHub
parent ae95c2b19b
commit 8c11c8f582
8 changed files with 8 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use {{{externCrateName}}}::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use multipart_v3::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use no_example_v3::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use openapi_v3::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use openapi_v3::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use ops_v3::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use petstore_with_fake_endpoints_models_for_testing::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");

View File

@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use rust_server_test::models;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
pub async fn create(addr: &str, https: bool) {
let addr = addr.parse().expect("Failed to parse bind address");