pub struct CraftWriter<W> { /* private fields */ }Expand description
Wraps some stream of type W, and implements either CraftSyncWriter or CraftAsyncWriter (or both)
based on what types W implements.
You can construct this type calling the function wrap_with_state, which requires you to specify
a packet direction (are written packets server-bound or client-bound?) and a state
(handshaking? login? status? play?).
This type holds some internal buffers but only allocates them when they are required.
Implementations§
Source§impl<W> CraftWriter<W>
impl<W> CraftWriter<W>
pub fn wrap(inner: W, direction: PacketDirection) -> Self
pub fn wrap_with_state( inner: W, direction: PacketDirection, state: State, ) -> Self
Trait Implementations§
Source§impl<W> CraftAsyncWriter for CraftWriter<W>where
W: AsyncWriteAll,
impl<W> CraftAsyncWriter for CraftWriter<W>where
W: AsyncWriteAll,
Source§fn write_packet_async<'life0, 'async_trait, P>(
&'life0 mut self,
packet: P,
) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + 'async_trait>>
fn write_packet_async<'life0, 'async_trait, P>( &'life0 mut self, packet: P, ) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + '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>>
fn write_raw_packet_async<'a, 'life0, 'async_trait, P>( &'life0 mut self, packet: P, ) -> Pin<Box<dyn Future<Output = WriteResult<()>> + Send + 'async_trait>>
Attempts to write a serialized packet to the wrapped stream. Read more
Source§impl<W> CraftIo for CraftWriter<W>
impl<W> CraftIo for CraftWriter<W>
Source§fn set_state(&mut self, next: State)
fn set_state(&mut self, next: State)
Changes the current connection state. For readers, this changes how numeric packet IDs are
interpreted. For writers, this will change the packets that can be written without a panic.
Source§fn set_compression_threshold(&mut self, threshold: Option<i32>)
fn set_compression_threshold(&mut self, threshold: Option<i32>)
Modifies the compression configuration. If a value of
None is provided, then compression is
disabled. If a value of Some is provided, then the threshold is set to that value. Read moreSource§fn enable_encryption(
&mut self,
key: &[u8],
iv: &[u8],
) -> Result<(), CipherError>
fn enable_encryption( &mut self, key: &[u8], iv: &[u8], ) -> Result<(), CipherError>
Modifies the encryption configuration. This function should only be called once, and can only
be used to enable encryption. Read more
Source§fn set_max_packet_size(&mut self, max_size: usize)
fn set_max_packet_size(&mut self, max_size: usize)
Sets the max packet size which this I/O wrapper will decode or transmit. Read more
fn ensure_buf_capacity(&mut self, capacity: usize)
fn ensure_compression_buf_capacity(&mut self, capacity: usize)
Source§impl<W> CraftSyncWriter for CraftWriter<W>where
W: Write,
impl<W> CraftSyncWriter for CraftWriter<W>where
W: Write,
Source§fn write_packet<P>(&mut self, packet: P) -> WriteResult<()>where
P: Packet,
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>,
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 Read more
Source§impl<W> CraftWrapper<W> for CraftWriter<W>
impl<W> CraftWrapper<W> for CraftWriter<W>
Source§fn into_inner(self) -> W
fn into_inner(self) -> W
Unwraps the wrapped value of type
I, and drops the wrapper typeAuto Trait Implementations§
impl<W> Freeze for CraftWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for CraftWriter<W>where
W: RefUnwindSafe,
impl<W> Send for CraftWriter<W>where
W: Send,
impl<W> Sync for CraftWriter<W>where
W: Sync,
impl<W> Unpin for CraftWriter<W>where
W: Unpin,
impl<W> UnwindSafe for CraftWriter<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more