Trait Server

Source
pub trait Server:
    Send
    + Sync
    + Sized {
    // Required methods
    fn open(url: &str) -> Option<Self>;
    fn close(self) -> Self;
    fn id(&self) -> ServerId;
    fn state(&self) -> ServerState;
    fn clients(&self) -> &[ClientId] ;
    fn disconnect(&mut self, id: ClientId);
    fn disconnect_all(&mut self);
    fn send(
        &mut self,
        id: ClientId,
        msg_id: MessageId,
        data: &[u8],
    ) -> Option<Range<usize>>;
    fn send_all(&mut self, id: MessageId, data: &[u8]);
    fn read(&mut self) -> Option<(ClientId, MessageId, Vec<u8>)>;

    // Provided methods
    fn read_all(&mut self) -> Vec<(ClientId, MessageId, Vec<u8>)> { ... }
    fn process(&mut self) { ... }
}

Required Methods§

Source

fn open(url: &str) -> Option<Self>

Source

fn close(self) -> Self

Source

fn id(&self) -> ServerId

Source

fn state(&self) -> ServerState

Source

fn clients(&self) -> &[ClientId]

Source

fn disconnect(&mut self, id: ClientId)

Source

fn disconnect_all(&mut self)

Source

fn send( &mut self, id: ClientId, msg_id: MessageId, data: &[u8], ) -> Option<Range<usize>>

Source

fn send_all(&mut self, id: MessageId, data: &[u8])

Source

fn read(&mut self) -> Option<(ClientId, MessageId, Vec<u8>)>

Provided Methods§

Source

fn read_all(&mut self) -> Vec<(ClientId, MessageId, Vec<u8>)>

Source

fn process(&mut self)

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.

Implementations on Foreign Types§

Source§

impl Server for ()

Source§

fn open(_: &str) -> Option<Self>

Source§

fn close(self) -> Self

Source§

fn id(&self) -> ServerId

Source§

fn state(&self) -> ServerState

Source§

fn clients(&self) -> &[ClientId]

Source§

fn disconnect(&mut self, _: ClientId)

Source§

fn disconnect_all(&mut self)

Source§

fn send(&mut self, _: ClientId, _: MessageId, _: &[u8]) -> Option<Range<usize>>

Source§

fn send_all(&mut self, _: MessageId, _: &[u8])

Source§

fn read(&mut self) -> Option<(ClientId, MessageId, Vec<u8>)>

Source§

fn read_all(&mut self) -> Vec<(ClientId, MessageId, Vec<u8>)>

Implementors§