CraftAsyncWriter

Trait CraftAsyncWriter 

Source
pub trait CraftAsyncWriter {
    // Required methods
    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 + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    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 + 'async_trait,
             Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait;
}
Expand description

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§

Source

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 + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

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

Source

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 + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§