[][src]Trait craftio_rs::CraftAsyncWriter

pub trait CraftAsyncWriter {
#[must_use]    pub fn write_packet_async<'life0, 'async_trait, P>(
        &'life0 mut self,
        packet: P
    ) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + 'async_trait>>
    where
        P: Packet + Send + Sync,
        P: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn write_raw_packet_async<'a, 'life0, 'async_trait, P>(
        &'life0 mut self,
        packet: P
    ) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + 'async_trait>>
    where
        P: RawPacket<'a> + Send + Sync,
        'a: 'async_trait,
        P: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
; }

This trait is the interface by which you can write packets to some underlying AsyncWrite stream

If you construct a CraftWriter by wrapping an AsyncWrite then CraftWriter will implement this trait.

Required methods

#[must_use]pub fn write_packet_async<'life0, 'async_trait, P>(
    &'life0 mut self,
    packet: P
) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + 'async_trait>> where
    P: Packet + Send + Sync,
    P: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Attempts to serialize, and then write a packet struct to the wrapped stream.

#[must_use]pub fn write_raw_packet_async<'a, 'life0, 'async_trait, P>(
    &'life0 mut self,
    packet: P
) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + 'async_trait>> where
    P: RawPacket<'a> + Send + Sync,
    'a: 'async_trait,
    P: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Attempts to write a serialized packet to the wrapped stream.

This function is most useful when forwarding packets from a reader. You can read raw packets from the reader, then match on the enum variant to conditionally deserialize only certain packet types to implement behavior, and leave other packets that are irrelevant to your application in their raw form.

Loading content...

Implementors

impl<R, W> CraftAsyncWriter for CraftConnection<R, W> where
    CraftReader<R>: CraftAsyncReader,
    R: Send + Sync,
    CraftWriter<W>: CraftAsyncWriter,
    W: Send + Sync
[src]

impl<W> CraftAsyncWriter for CraftWriter<W> where
    W: AsyncWriteAll
[src]

Loading content...