Trait Network

Source
pub trait Network {
    // Required methods
    fn send<'life0, 'async_trait>(
        &'life0 mut self,
        source: i32,
        msg: String,
    ) -> Pin<Box<dyn Future<Output = NetworkResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn receive<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = NetworkResult<NetworkUpdate>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

This trait represent a network that will be used to send and receive messages

Required Methods§

Source

fn send<'life0, 'async_trait>( &'life0 mut self, source: i32, msg: String, ) -> Pin<Box<dyn Future<Output = NetworkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a message to the network

§Arguments
  • source - The source of the message
  • msg - The message to send
§Returns
  • Ok(()) - If the message has been sent
  • Err(e) - If an error occurred
Source

fn receive<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = NetworkResult<NetworkUpdate>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive a message from the network

§Returns
  • Ok(NetworkUpdate) - If a message has been received
  • Err(e) - If an error occurred

Implementors§