pub struct MidReader<R, D> { /* private fields */ }
Implementations§
Source§impl<R, D> MidReader<R, D>
impl<R, D> MidReader<R, D>
Sourcepub async fn read_compressed(
&mut self,
size: usize,
strategy: DecompressionStrategy,
) -> Result<Vec<u8>, CompressedReadError>
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,
impl<R, D> MidReader<R, D>where
R: AsyncReadExt + Unpin,
Sourcepub async fn skip_n_bytes(&mut self, nbytes: usize) -> Result<()>
pub async fn skip_n_bytes(&mut self, nbytes: usize) -> Result<()>
Skips nbytes
bytes from the underlying stream.
Sourcepub async fn read_raw_packet_type(&mut self) -> Result<(u8, u8)>
pub async fn read_raw_packet_type(&mut self) -> Result<(u8, u8)>
Reads packet type and decodes it returning pair of
u8
’s
Sourcepub async fn read_string_prefixed(&mut self) -> Result<String>
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.
Sourcepub async fn read_string(&mut self, bytes_size: usize) -> Result<String>
pub async fn read_string(&mut self, bytes_size: usize) -> Result<String>
Reads string of size bytes_size
with lossy utf8
decoding.
Sourcepub async fn read_bytes_prefixed(&mut self) -> Result<Vec<u8>>
pub async fn read_bytes_prefixed(&mut self) -> Result<Vec<u8>>
Reads prefixed buffer with max size of u8::MAX
.
Sourcepub fn read_u8(&mut self) -> impl Future<Output = Result<u8>> + '_
pub fn read_u8(&mut self) -> impl Future<Output = Result<u8>> + '_
Read u8
from the underlying stream
Sourcepub fn read_u16(&mut self) -> impl Future<Output = Result<u16>> + '_
pub fn read_u16(&mut self) -> impl Future<Output = Result<u16>> + '_
Read u16
from the underlying stream (little
endian)
Sourcepub fn read_u32(&mut self) -> impl Future<Output = Result<u32>> + '_
pub fn read_u32(&mut self) -> impl Future<Output = Result<u32>> + '_
Read u32
from the underlying stream (little
endian)
Sourcepub async fn read_buffer(&mut self, size: usize) -> Result<Vec<u8>>
pub async fn read_buffer(&mut self, size: usize) -> Result<Vec<u8>>
Read size
bytes from the socket without buffer
pre-filling.
Sourcepub fn read_length(
&mut self,
flags: u8,
) -> impl Future<Output = Result<u16>> + '_
pub fn read_length( &mut self, flags: u8, ) -> impl Future<Output = Result<u16>> + '_
Reads variadic length of payload from the stream
Source§impl<R, D> MidReader<R, D>where
R: AsyncRead,
impl<R, D> MidReader<R, D>where
R: AsyncRead,
Sourcepub fn make_buffered(
self,
buffer_size: usize,
decompressor: D,
) -> MidReader<BufReader<R>, D>
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)
Auto Trait Implementations§
impl<R, D> Freeze for MidReader<R, D>
impl<R, D> RefUnwindSafe for MidReader<R, D>where
R: RefUnwindSafe,
D: RefUnwindSafe,
impl<R, D> Send for MidReader<R, D>
impl<R, D> Sync for MidReader<R, D>
impl<R, D> Unpin for MidReader<R, D>
impl<R, D> UnwindSafe for MidReader<R, D>where
R: UnwindSafe,
D: 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