Trait SocketEmitter

Source
pub trait SocketEmitter:
    Send
    + Sync
    + 'static {
    type AckError: StdError + Send + Serialize + DeserializeOwned + 'static;
    type AckStream: Stream<Item = AckStreamItem<Self::AckError>> + FusedStream + Send + 'static;

    // Required methods
    fn get_all_sids(&self, filter: impl Fn(&Sid) -> bool) -> Vec<Sid>;
    fn get_remote_sockets(
        &self,
        sids: BroadcastIter<'_>,
    ) -> Vec<RemoteSocketData>;
    fn send_many(
        &self,
        sids: BroadcastIter<'_>,
        data: Value,
    ) -> Result<(), Vec<SocketError>>;
    fn send_many_with_ack(
        &self,
        sids: BroadcastIter<'_>,
        packet: Packet,
        timeout: Option<Duration>,
    ) -> (Self::AckStream, u32);
    fn disconnect_many(&self, sids: Vec<Sid>) -> Result<(), Vec<SocketError>>;
    fn path(&self) -> &Str;
    fn parser(&self) -> impl Parse;
    fn server_id(&self) -> Uid;
}
Expand description

The SocketEmitter will be implemented by the socketioxide library. It is simply used as an abstraction to allow the adapter to communicate with the socket server without the need to depend on the socketioxide lib.

Required Associated Types§

Source

type AckError: StdError + Send + Serialize + DeserializeOwned + 'static

An error that can occur when sending data an acknowledgment.

Source

type AckStream: Stream<Item = AckStreamItem<Self::AckError>> + FusedStream + Send + 'static

A stream that emits the acknowledgments of multiple sockets.

Required Methods§

Source

fn get_all_sids(&self, filter: impl Fn(&Sid) -> bool) -> Vec<Sid>

Get all the socket ids in the namespace.

Source

fn get_remote_sockets(&self, sids: BroadcastIter<'_>) -> Vec<RemoteSocketData>

Get the socket data that match the list of socket ids.

Source

fn send_many( &self, sids: BroadcastIter<'_>, data: Value, ) -> Result<(), Vec<SocketError>>

Send data to the list of socket ids.

Source

fn send_many_with_ack( &self, sids: BroadcastIter<'_>, packet: Packet, timeout: Option<Duration>, ) -> (Self::AckStream, u32)

Send data to the list of socket ids and get a stream of acks and the number of expected acks.

Source

fn disconnect_many(&self, sids: Vec<Sid>) -> Result<(), Vec<SocketError>>

Disconnect all the sockets in the list. TODO: take a BroadcastIter. Currently it is impossible because it may create deadlocks with Adapter::del_all call.

Source

fn path(&self) -> &Str

Get the path of the namespace.

Source

fn parser(&self) -> impl Parse

Get the parser of the namespace.

Source

fn server_id(&self) -> Uid

Get the unique server id.

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§