diff --git a/src/app.rs b/src/app.rs index c529e14e..f4e4c030 100644 --- a/src/app.rs +++ b/src/app.rs @@ -171,8 +171,8 @@ where /// # Type Parameters /// /// This method changes the connection state type parameter from `C` to `C2`. - /// This means that any subsequent builder methods will operate on the new connection state type `C2`. - /// Be aware of this type transition when chaining builder methods. + /// This means that any subsequent builder methods will operate on the new connection state type + /// `C2`. Be aware of this type transition when chaining builder methods. /// /// # Errors /// diff --git a/src/server.rs b/src/server.rs index c5b5bc00..c0e0bb7b 100644 --- a/src/server.rs +++ b/src/server.rs @@ -17,6 +17,12 @@ use std::{ }; use bincode::error::DecodeError; + +/// Callback invoked when a connection preamble decodes successfully. +pub type PreambleCallback = Arc; + +/// Callback invoked when decoding a connection preamble fails. +pub type PreambleErrorCallback = Arc; use tokio::{ net::TcpListener, sync::broadcast, @@ -36,7 +42,6 @@ use crate::{ /// closure. The server listens for a shutdown signal using /// `tokio::signal::ctrl_c` and notifies all workers to stop /// accepting new connections. -#[allow(clippy::type_complexity)] pub struct WireframeServer where F: Fn() -> WireframeApp + Send + Sync + Clone + 'static, @@ -47,8 +52,8 @@ where factory: F, listener: Option>, workers: usize, - on_preamble_success: Option>, - on_preamble_failure: Option>, + on_preamble_success: Option>, + on_preamble_failure: Option, _preamble: PhantomData, } @@ -340,7 +345,6 @@ where } } -#[allow(clippy::type_complexity)] /// Runs a worker task that accepts incoming TCP connections and processes them asynchronously. /// /// Each accepted connection is handled in a separate task, with optional callbacks for preamble @@ -349,8 +353,8 @@ where async fn worker_task( listener: Arc, factory: F, - on_success: Option>, - on_failure: Option>, + on_success: Option>, + on_failure: Option, // Each worker owns its shutdown receiver. mut shutdown_rx: broadcast::Receiver<()>, ) where @@ -380,7 +384,6 @@ async fn worker_task( } } -#[allow(clippy::type_complexity)] /// Processes an incoming TCP stream by decoding a preamble and dispatching the connection to a /// `WireframeApp`. /// @@ -409,8 +412,8 @@ async fn worker_task( async fn process_stream( mut stream: tokio::net::TcpStream, factory: F, - on_success: Option>, - on_failure: Option>, + on_success: Option>, + on_failure: Option, ) where F: Fn() -> WireframeApp + Send + Sync + 'static, // `Preamble` ensures `T` supports borrowed decoding.