Struct MidReader

Source
pub struct MidReader<R, D> { /* private fields */ }

Implementations§

Source§

impl<R, D> MidReader<R, D>

Source

pub async fn read_compressed( &mut self, size: usize, strategy: DecompressionStrategy, ) -> Result<Vec<u8>, CompressedReadError>

Reads compressed pile of bytes from the stream

Source§

impl<R, D> MidReader<R, D>
where R: AsyncReadExt + Unpin,

Source

pub async fn skip_n_bytes(&mut self, nbytes: usize) -> Result<()>

Skips nbytes bytes from the underlying stream.

Source

pub async fn read_raw_packet_type(&mut self) -> Result<(u8, u8)>

Reads packet type and decodes it returning pair of u8’s

Source

pub async fn read_string_prefixed(&mut self) -> Result<String>

Reads string of prefixed size with max size of u8::MAX, uses lossy utf8 decoding.

Source

pub async fn read_string(&mut self, bytes_size: usize) -> Result<String>

Reads string of size bytes_size with lossy utf8 decoding.

Source

pub async fn read_bytes_prefixed(&mut self) -> Result<Vec<u8>>

Reads prefixed buffer with max size of u8::MAX.

Source

pub fn read_u8(&mut self) -> impl Future<Output = Result<u8>> + '_

Read u8 from the underlying stream

Source

pub fn read_u16(&mut self) -> impl Future<Output = Result<u16>> + '_

Read u16 from the underlying stream (little endian)

Source

pub fn read_u32(&mut self) -> impl Future<Output = Result<u32>> + '_

Read u32 from the underlying stream (little endian)

Source

pub async fn read_buffer(&mut self, size: usize) -> Result<Vec<u8>>

Read size bytes from the socket without buffer pre-filling.

Source

pub fn read_length( &mut self, flags: u8, ) -> impl Future<Output = Result<u16>> + '_

Reads variadic length of payload from the stream

Source

pub fn read_client_id( &mut self, flags: u8, ) -> impl Future<Output = Result<u16>> + '_

Reads variadic client id from the stream

Source

pub async fn read_variadic( &mut self, current_flags: u8, needed: u8, ) -> Result<u16>

Reads u8 or u16 from the stream, depending on flags.

Source§

impl<R, D> MidReader<R, D>
where R: AsyncRead,

Source

pub fn make_buffered( self, buffer_size: usize, decompressor: D, ) -> MidReader<BufReader<R>, D>

Create buffered reader (wraps R with BufReader<R> with specified capacity)

Source§

impl<R, D> MidReader<BufReader<R>, D>
where R: AsyncRead,

Source

pub fn new_buffered(socket: R, decompressor: D, buffer_size: usize) -> Self

Create buffered version of the reader

Source

pub fn unbuffer(self) -> MidReader<R, D>

Remove underlying buffer.

WARNING: buffered data can be lost!

Source§

impl<R, D> MidReader<R, D>

Source

pub const fn socket(&self) -> &R

Get shared access to the underlying socket

Source

pub fn socket_mut(&mut self) -> &mut R

Get exclusive access to the underlying socket

Source

pub const fn new(socket: R, decompressor: D) -> Self

Simply create reader from the underlying socket type

Auto Trait Implementations§

§

impl<R, D> Freeze for MidReader<R, D>
where R: Freeze, D: Freeze,

§

impl<R, D> RefUnwindSafe for MidReader<R, D>

§

impl<R, D> Send for MidReader<R, D>
where R: Send, D: Send,

§

impl<R, D> Sync for MidReader<R, D>
where R: Sync, D: Sync,

§

impl<R, D> Unpin for MidReader<R, D>
where R: Unpin, D: Unpin,

§

impl<R, D> UnwindSafe for MidReader<R, D>
where R: UnwindSafe, D: 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, 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.