Trait veloren_network_protocol::SendProtocol

source ·
pub trait SendProtocol {
    type CustomErr: Debug + Send;

    // Required methods
    fn notify_from_recv(&mut self, event: ProtocolEvent);
    fn send<'life0, 'async_trait>(
        &'life0 mut self,
        event: ProtocolEvent,
    ) -> Pin<Box<dyn Future<Output = Result<(), ProtocolError<Self::CustomErr>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn flush<'life0, 'async_trait>(
        &'life0 mut self,
        bandwidth: Bandwidth,
        dt: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Bandwidth, ProtocolError<Self::CustomErr>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Generic Network Send Protocol. Implement this for your Protocol of choice ( tcp, udp, mpsc, quic) Allows the creation/deletions of Streams and sending messages via ProtocolEvent.

A Stream MUST be bound to a specific Channel. You MUST NOT switch the channel to send a stream mid air. We will provide takeover options for Channel closure in the future to allow keeping a Stream over a broken Channel.

Required Associated Types§

Required Methods§

source

fn notify_from_recv(&mut self, event: ProtocolEvent)

YOU MUST inform the SendProtocol by any Stream Open BEFORE using it in send and Stream Close AFTER using it in send via this fn.

source

fn send<'life0, 'async_trait>( &'life0 mut self, event: ProtocolEvent, ) -> Pin<Box<dyn Future<Output = Result<(), ProtocolError<Self::CustomErr>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a Event via this Protocol. The SendProtocol MAY require flush to be called before actual data is send to the respective Sink.

source

fn flush<'life0, 'async_trait>( &'life0 mut self, bandwidth: Bandwidth, dt: Duration, ) -> Pin<Box<dyn Future<Output = Result<Bandwidth, ProtocolError<Self::CustomErr>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Flush all buffered messages according to their Prio and Bandwidth. provide the current bandwidth budget (per second) as well as the dt since last call. According to the budget the respective messages will be flushed.

Implementors§