diff --git a/src/lib.rs b/src/lib.rs index a37a529..2ab9d7e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -211,6 +211,14 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream }; // Create a struct to implement the communication between the server and the client + #[cfg(feature = "tcp")] + let listener_statement = quote! { + let listener = #listener_type::bind(addr).await?; + }; + #[cfg(feature = "unix")] + let listener_statement = quote! { + let listener = #listener_type::bind(addr.as_ref())?; + }; let sc_struct = quote! { #vis struct #server_connection_struct_name { handler: ::std::sync::Arc>, @@ -218,7 +226,7 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream } impl #server_connection_struct_name { pub async fn bind(handler: H, addr: S) -> Result { - let listener = #listener_type::bind(addr).await?; + #listener_statement let (stream, _) = listener.accept().await?; Ok(Self { handler: ::std::sync::Arc::new(tokio::sync::Mutex::new(handler)),