Trait TransportSenderT

Source
pub trait TransportSenderT: 'static {
    type Error: Error + Send + Sync;

    // Required method
    fn send(
        &mut self,
        msg: String,
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;

    // Provided methods
    fn send_ping(
        &mut self,
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend { ... }
    fn close(
        &mut self,
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend { ... }
}
Available on crate feature client only.
Expand description

Transport interface to send data asynchronous.

Required Associated Types§

Source

type Error: Error + Send + Sync

Error that may occur during sending a message.

Required Methods§

Source

fn send( &mut self, msg: String, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Send.

Provided Methods§

Source

fn send_ping( &mut self, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

This is optional because it’s most likely relevant for WebSocket transports only. You should only implement this is your transport supports sending periodic pings.

Send ping frame (opcode of 0x9).

Source

fn close(&mut self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

This is optional because it’s most likely relevant for WebSocket transports only. You should only implement this is your transport supports being closed.

Send customized close message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§