Skip to content

Commit

Permalink
Removed async from ServerBuilder::build
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdejager committed May 16, 2024
1 parent 4753c20 commit b5d58eb
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion crates/unftp-auth-jsonfile/examples/jsonfile_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = libunftp::Server::with_fs(std::env::temp_dir())
.authenticator(Arc::new(authenticator))
.build()
.await
.unwrap();

println!("Starting ftp server on {}", addr);
Expand Down
1 change: 0 additions & 1 deletion crates/unftp-auth-rest/examples/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = libunftp::Server::with_fs(std::env::temp_dir())
.authenticator(Arc::new(authenticator))
.build()
.await
.unwrap();

println!("Starting ftp server on {}", addr);
Expand Down
2 changes: 1 addition & 1 deletion crates/unftp-sbe-fs/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async fn main() {
pretty_env_logger::init();

let addr = "127.0.0.1:2121";
let server = libunftp::Server::with_fs(std::env::temp_dir()).build().await.unwrap();
let server = libunftp::Server::with_fs(std::env::temp_dir()).build().unwrap();

println!("Starting ftp server on {}", addr);
server.listen(addr).await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/unftp-sbe-fs/examples/cap-ftpd-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ async fn main() {
sb = sb.binder(binder);
}
}
let server: Server<Filesystem, User> = sb.build().await.unwrap();
let server: Server<Filesystem, User> = sb.build().unwrap();
cfg_if! {
if #[cfg(target_os = "freebsd")] {
capsicum::enter().unwrap();
Expand Down
1 change: 0 additions & 1 deletion crates/unftp-sbe-fs/examples/cap-ftpd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async fn main() {
let server = libunftp::Server::with_fs(std::env::temp_dir())
.connection_helper(helper.into(), helper_args)
.build()
.await
.unwrap();

println!("Starting ftp server on {}", addr);
Expand Down
1 change: 0 additions & 1 deletion crates/unftp-sbe-fs/examples/proxyprotocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ async fn main() {
.proxy_protocol_mode(2121)
.passive_ports(5000..5005)
.build()
.await
.unwrap();

println!("Starting ftp server with proxy protocol on {}", addr);
Expand Down
1 change: 0 additions & 1 deletion crates/unftp-sbe-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! .greeting("Welcome to my FTP server")
//! .passive_ports(50000..65535)
//! .build()
//! .await
//! .unwrap();
//!
//! server.listen("127.0.0.1:2121").await;
Expand Down
2 changes: 1 addition & 1 deletion crates/unftp-sbe-fs/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where
let tempdir = tempfile::TempDir::new().unwrap();
let root = tempdir.path().to_path_buf();

let server = s(root.clone()).build().await.unwrap().listen(addr.clone());
let server = s(root.clone()).build().unwrap().listen(addr.clone());

tokio::spawn(server);
while async_ftp::FtpStream::connect(&addr).await.is_err() {
Expand Down
2 changes: 0 additions & 2 deletions crates/unftp-sbe-gcs/examples/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
}))
.ftps(ftps_certs_file, ftps_key_file)
.build()
.await
.unwrap()
.listen(BIND_ADDRESS)
.await?;
Expand All @@ -101,7 +100,6 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
unftp_sbe_gcs::CloudStorage::with_api_base(&gcs_base_url, &bucket_name, PathBuf::new(), service_account_key.clone())
}))
.build()
.await
.unwrap()
.listen(BIND_ADDRESS)
.await?;
Expand Down
2 changes: 0 additions & 2 deletions crates/unftp-sbe-gcs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
//! .greeting("Welcome to my FTP server")
//! .passive_ports(50000..65535)
//! .build()
//! .await
//! .unwrap();
//!
//! server.listen("127.0.0.1:2121").await;
Expand All @@ -50,7 +49,6 @@
//! .greeting("Welcome to my FTP server")
//! .passive_ports(50000..65535)
//! .build()
//! .await
//! .unwrap();
//!
//! server.listen("127.0.0.1:2121").await;
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
//! .greeting("Welcome to my FTP server")
//! .passive_ports(50000..65535)
//! .build()
//! .await
//! .unwrap();
//!
//! server.listen("127.0.0.1:2121").await;
Expand Down
6 changes: 3 additions & 3 deletions src/server/ftpserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use std::{ffi::OsString, fmt::Debug, future::Future, net::SocketAddr, ops::Range
///
/// let mut rt = Runtime::new().unwrap();
/// rt.spawn(async {
/// let server = Server::with_fs("/srv/ftp").build().await.unwrap();
/// let server = Server::with_fs("/srv/ftp").build().unwrap();
/// server.listen("127.0.0.1:2121").await.unwrap()
/// });
/// ```
Expand Down Expand Up @@ -205,7 +205,7 @@ where
}

/// Finalize the options and build a [`Server`].
pub async fn build(self) -> std::result::Result<Server<Storage, User>, ServerError> {
pub fn build(self) -> std::result::Result<Server<Storage, User>, ServerError> {
let ftps_mode = match self.ftps_mode {
FtpsConfig::Off => FtpsConfig::Off,
FtpsConfig::Building { certs_file, key_file } => FtpsConfig::On {
Expand Down Expand Up @@ -685,7 +685,7 @@ where
///
/// let mut rt = Runtime::new().unwrap();
/// rt.spawn(async {
/// let server = Server::with_fs("/srv/ftp").build().await.unwrap();
/// let server = Server::with_fs("/srv/ftp").build().unwrap();
/// server.listen("127.0.0.1:2121").await
/// });
/// // ...
Expand Down
1 change: 0 additions & 1 deletion tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub async fn run_with_auth() {
.greeting("Welcome test")
.failed_logins_policy(FailedLoginsPolicy::new(3, std::time::Duration::new(5, 0), FailedLoginsBlock::User))
.build()
.await
.unwrap();
server.listen(addr).await.unwrap();
}
Expand Down

0 comments on commit b5d58eb

Please sign in to comment.