pub trait ServerApp {
// Required method
fn process_new<'life0, 'life1, 'async_trait>(
self: &'life0 Arc<Self>,
session: Box<dyn IO>,
shutdown: &'life1 Receiver<bool>,
) -> Pin<Box<dyn Future<Output = Option<Box<dyn IO>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided method
fn cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: Sync + 'async_trait { ... }
}Expand description
This trait defines the interface of a transport layer (TCP or TLS) application.
Required Methods§
Sourcefn process_new<'life0, 'life1, 'async_trait>(
self: &'life0 Arc<Self>,
session: Box<dyn IO>,
shutdown: &'life1 Receiver<bool>,
) -> Pin<Box<dyn Future<Output = Option<Box<dyn IO>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn process_new<'life0, 'life1, 'async_trait>(
self: &'life0 Arc<Self>,
session: Box<dyn IO>,
shutdown: &'life1 Receiver<bool>,
) -> Pin<Box<dyn Future<Output = Option<Box<dyn IO>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Whenever a new connection is established, this function will be called with the established
Stream object provided.
The application can do whatever it wants with the session.
After processing the session, if the session’s connection is reusable, This function
can return it to the service by returning Some(session). The returned session will be
fed to another Self::process_new() for another round of processing.
If not reusable, None should be returned.
The shutdown argument will change from false to true when the server receives a
signal to shutdown. This argument allows the application to react accordingly.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.