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]
A: ToSocketAddrs,
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]
M: From<Message>,
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]
&self
) -> Option<Result<Event<M>, <M as TryFrom<Message>>::Error>> where
M: TryFrom<Message>,
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]
M: Into<Message>,
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]
&self,
id: Option<u128>,
msg: M
) -> Result<Result<()>, <M as TryInto<Message>>::Error> where
M: TryInto<Message>,
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]
self: &Arc<Self>,
id: Option<u128>,
reason: &str
) -> Result<()>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,