CraftSyncWriter

Trait CraftSyncWriter 

Source
pub trait CraftSyncWriter {
    // Required methods
    fn write_packet<P>(&mut self, packet: P) -> WriteResult<()>
       where P: Packet;
    fn write_raw_packet<'a, P>(&mut self, packet: P) -> WriteResult<()>
       where P: RawPacket<'a>;
}
Expand description

This trait is the interface by which you can write packets to some underlying implementor of std::io::Write.

If you construct a CraftWriter by wrapping a std::io::Write implementor then CraftWriter will implement this trait.

Required Methods§

Source

fn write_packet<P>(&mut self, packet: P) -> WriteResult<()>
where P: Packet,

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

Source

fn write_raw_packet<'a, P>(&mut self, packet: P) -> WriteResult<()>
where P: RawPacket<'a>,

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§