Trait Server

Source
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§

Source

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.

Source

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.

Source

fn name(&self) -> &str

Provided Methods§

Source

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.

Implementors§