pub trait ChatServer: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn listeners(&self) -> Vec<&dyn ChatListener>;
fn run<'life0, 'async_trait, F, Fut>(
&'life0 mut self,
handler: F,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where F: Fn(Message) -> Fut + Send + Sync + 'static + 'async_trait,
Fut: Future<Output = Result<Option<String>>> + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A protocol-agnostic chat server.
A server is defined by its name and the set of ChatListeners attached
to it. It has no inherent address, port, or protocol — those are properties
of the individual listeners.
Required Methods§
Sourcefn listeners(&self) -> Vec<&dyn ChatListener>
fn listeners(&self) -> Vec<&dyn ChatListener>
Snapshot of all currently attached listeners (for introspection).
Sourcefn run<'life0, 'async_trait, F, Fut>(
&'life0 mut self,
handler: F,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn run<'life0, 'async_trait, F, Fut>( &'life0 mut self, handler: F, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Start all listeners and run the server event loop.
Blocks until all listeners have exited (either through
ChatServer::shutdown or because they finished naturally).
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.