Struct paperplane::Server[][src]

pub struct Server { /* fields omitted */ }

A TCP WebSocket Server.

Implementations

impl Server[src]

pub fn new(cap: usize) -> Arc<Self>[src]

Create a new Server instance. Takes a capacity for channel and returns Arc<Server> for convenience.

pub async fn connections(&self) -> Vec<u128>[src]

List connection ids.

pub async fn listen<A>(self: &Arc<Self>, addr: A) -> Result<()> where
    A: ToSocketAddrs
[src]

Start listening on given socket address.

pub async fn close(self: &Arc<Self>) -> Result<()>[src]

Close all connections and stop all listeners.

pub async fn next<M>(&self) -> Option<Event<M>> where
    M: From<Message>, 
[src]

Get next server event.

pub async fn next_transform<M>(
    &self
) -> Option<Result<Event<M>, <M as TryFrom<Message>>::Error>> where
    M: TryFrom<Message>, 
[src]

Get next server event and try converting if it’s a Event::Message.

pub async fn send<M>(&self, id: Option<u128>, msg: M) -> Result<()> where
    M: Into<Message>, 
[src]

Send a message to a connection with the given id. If id is None then the messages will be sent to all connections.

pub async fn send_transform<M>(
    &self,
    id: Option<u128>,
    msg: M
) -> Result<Result<()>, <M as TryInto<Message>>::Error> where
    M: TryInto<Message>, 
[src]

Try converting the message and send to a connection with the given id. If id is None then the messages will be sent to all connections.

pub async fn kick(
    self: &Arc<Self>,
    id: Option<u128>,
    reason: &str
) -> Result<()>
[src]

Close a connection with the given id and reason. If id is None then all connections will be closed.

Auto Trait Implementations

impl !RefUnwindSafe for Server

impl Send for Server

impl Sync for Server

impl Unpin for Server

impl !UnwindSafe for Server

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,