CraftReader

Struct CraftReader 

Source
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>

Source

pub fn wrap(inner: R, direction: PacketDirection) -> Self

Source

pub fn wrap_with_state( inner: R, direction: PacketDirection, state: State, ) -> Self

Trait Implementations§

Source§

impl<R> CraftAsyncReader for CraftReader<R>
where R: AsyncReadExact,

Source§

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,

Source§

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,

Source§

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>>
where P: RawPacket<'a> + 'async_trait, Self: Send + 'async_trait, 'a: 'async_trait,

Source§

impl<R> CraftIo for CraftReader<R>

Source§

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>)

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 more
Source§

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)

Sets the max packet size which this I/O wrapper will decode or transmit. Read more
Source§

fn ensure_buf_capacity(&mut self, capacity: usize)

Source§

fn ensure_compression_buf_capacity(&mut self, capacity: usize)

Source§

impl<R> CraftSyncReader for CraftReader<R>
where R: Read,

Source§

fn read_raw_packet<'a, P>(&'a mut self) -> ReadResult<P>
where P: RawPacket<'a>,

Source§

fn read_raw_untyped_packet(&mut self) -> ReadResult<(Id, &[u8])>

Source§

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>

Source§

fn into_inner(self) -> R

Unwraps the wrapped value of type I, and drops the wrapper type

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V