[][src]Struct turbulence::unreliable_bincode_channel::UnreliableBincodeChannel

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

Wraps an UnreliableChannel together with an internal buffer to allow easily sending message types serialized with bincode.

Just like the underlying channel, messages are not guaranteed to arrive, nor are they guaranteed to arrive in order.

Implementations

impl<P> UnreliableBincodeChannel<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<T: Serialize, '_, '_>(
    &'_ mut self,
    msg: &'_ T
) -> Result<(), SendError>
[src]

Write the given serializable message type 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<'a, T: Deserialize<'a>>(&'a mut self) -> Result<T, RecvError>[src]

Receive a deserializable message type as soon as the next message is available.

Auto Trait Implementations

impl<P> !RefUnwindSafe for UnreliableBincodeChannel<P>

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

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

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

impl<P> !UnwindSafe for UnreliableBincodeChannel<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.