Skip to main content

Server

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;
    fn as_any(&self) -> &dyn Any;

    // 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

Source

fn as_any(&self) -> &dyn Any

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§