pub trait Server: Send + Sync {
// Required methods
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn start<'life0, 'async_trait>(
&'life0 mut self,
listening: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn name(&self) -> &str;
// Provided method
fn bind_addr(&self) -> Option<SocketAddr> { ... }
}
Required Methods§
Sourcefn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Shutdown the server gracefully.
Sourcefn start<'life0, 'async_trait>(
&'life0 mut self,
listening: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
listening: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Starts the server and binds on listening
.
Caller should ensure start()
is only invoked once.
fn name(&self) -> &str
Provided Methods§
Sourcefn bind_addr(&self) -> Option<SocketAddr>
fn bind_addr(&self) -> Option<SocketAddr>
Finds the actual bind address of this server.
If not found (returns None
), maybe it’s not started yet, or just don’t have it.