[][src]Struct turbulence::unreliable_channel::UnreliableChannel

pub struct UnreliableChannel<P> where
    P: PacketPool
{ /* fields omitted */ }

Turns a stream of unreliable, unordered packets into a stream of unreliable, unordered messages.

Implementations

impl<P> UnreliableChannel<P> where
    P: PacketPool
[src]

pub fn new(
    packet_pool: P,
    incoming: Receiver<P::Packet>,
    outgoing: Sender<P::Packet>
) -> Self
[src]

pub async fn send<'_, '_>(&'_ mut self, msg: &'_ [u8]) -> Result<(), SendError>[src]

Write the given message to the channel.

Messages are coalesced into larger packets before being sent, so in order to guarantee that the message is actually sent, you must call flush.

pub async fn flush<'_>(&'_ mut self) -> Result<(), SendError>[src]

Finish sending any unsent coalesced packets.

This must be called to guarantee that any sent messages are actually sent to the outgoing packet stream.

pub async fn recv<'_, '_>(
    &'_ mut self,
    msg: &'_ mut [u8]
) -> Result<usize, RecvError>
[src]

Receive a message into the provide buffer.

If the received message fits into the provided buffer, this will return Ok(message_len), otherwise it will return Err(RecvError::TooBig).

Auto Trait Implementations

impl<P> !RefUnwindSafe for UnreliableChannel<P>

impl<P> Send for UnreliableChannel<P> where
    P: Send,
    <P as PacketPool>::Packet: Send

impl<P> Sync for UnreliableChannel<P> where
    P: Sync,
    <P as PacketPool>::Packet: Send + Sync

impl<P> Unpin for UnreliableChannel<P> where
    P: Unpin,
    <P as PacketPool>::Packet: Unpin

impl<P> !UnwindSafe for UnreliableChannel<P>

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, 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.