pub struct CraftReader<R> { /* private fields */ }Expand description
Wraps some stream of type R, and implements either CraftSyncReader or CraftAsyncReader (or both)
based on what types R 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<R> CraftReader<R>
impl<R> CraftReader<R>
pub fn wrap(inner: R, direction: PacketDirection) -> Self
pub fn wrap_with_state( inner: R, direction: PacketDirection, state: State, ) -> Self
Trait Implementations§
Source§impl<R> CraftAsyncReader for CraftReader<R>where
R: AsyncReadExact,
impl<R> CraftAsyncReader for CraftReader<R>where
R: AsyncReadExact,
fn read_raw_packet_async<'a, 'async_trait, P>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = ReadResult<P>> + Send + 'async_trait>>where
P: RawPacket<'a> + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
fn read_raw_untyped_packet_async<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ReadResult<(Id, &[u8])>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_packet_async<'a, 'async_trait, P>( &'a mut self, ) -> Pin<Box<dyn Future<Output = ReadResult<<P as RawPacket<'a>>::Packet>> + Send + 'async_trait>>
Source§impl<R> CraftIo for CraftReader<R>
impl<R> CraftIo for CraftReader<R>
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<R> CraftSyncReader for CraftReader<R>where
R: Read,
impl<R> CraftSyncReader for CraftReader<R>where
R: Read,
fn read_raw_packet<'a, P>(&'a mut self) -> ReadResult<P>where
P: RawPacket<'a>,
fn read_raw_untyped_packet(&mut self) -> ReadResult<(Id, &[u8])>
fn read_packet<'a, P>(&'a mut self) -> ReadResult<<P as RawPacket<'a>>::Packet>where
P: RawPacket<'a>,
Source§impl<R> CraftWrapper<R> for CraftReader<R>
impl<R> CraftWrapper<R> for CraftReader<R>
Source§fn into_inner(self) -> R
fn into_inner(self) -> R
Unwraps the wrapped value of type
I, and drops the wrapper typeAuto Trait Implementations§
impl<R> Freeze for CraftReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for CraftReader<R>where
R: RefUnwindSafe,
impl<R> Send for CraftReader<R>where
R: Send,
impl<R> Sync for CraftReader<R>where
R: Sync,
impl<R> Unpin for CraftReader<R>where
R: Unpin,
impl<R> UnwindSafe for CraftReader<R>where
R: 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