Struct fixed_buffer_tokio::AsyncFixedBuf
source · [−]pub struct AsyncFixedBuf<const SIZE: usize>(_);
Expand description
A newtype that wraps
FixedBuf
and implements
tokio::io::AsyncRead
and
tokio::io::AsyncWrite
.
It also has async versions of FixedBuf’s io functions.
Implementations
sourceimpl<const SIZE: usize> AsyncFixedBuf<SIZE>
impl<const SIZE: usize> AsyncFixedBuf<SIZE>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new FixedBuf and wraps it in an AsyncFixedBuf.
See
FixedBuf::new
for details.
sourcepub fn into_inner(self) -> FixedBuf<SIZE>
pub fn into_inner(self) -> FixedBuf<SIZE>
Drops the struct and returns its internal
FixedBuf
.
sourcepub fn empty(mem: [u8; SIZE]) -> Self
pub fn empty(mem: [u8; SIZE]) -> Self
Makes a new empty buffer.
Consumes mem
and uses it as the internal memory array.
sourcepub fn filled(mem: [u8; SIZE]) -> Self
pub fn filled(mem: [u8; SIZE]) -> Self
Makes a new full buffer containing the bytes in mem
.
Reading the buffer will return the bytes in mem
.
Consumes mem
and uses it as the internal memory array.
Methods from Deref<Target = FixedBuf<SIZE>>
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of unread bytes in the buffer.
Example:
let mut buf: FixedBuf<16> = FixedBuf::new();
assert_eq!(0, buf.len());
buf.write_str("abc");
assert_eq!(3, buf.len());
buf.read_bytes(2);
assert_eq!(1, buf.len());
buf.shift();
assert_eq!(1, buf.len());
buf.read_all();
assert_eq!(0, buf.len());
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are unread bytes in the buffer.
Example:
let mut buf: FixedBuf<16> = FixedBuf::new();
assert!(buf.is_empty());
buf.write_str("abc").unwrap();
assert!(!buf.is_empty());
buf.read_all();
assert!(buf.is_empty());
sourcepub fn escape_ascii(&self) -> String
pub fn escape_ascii(&self) -> String
Copies all readable bytes to a string. Includes printable ASCII characters as-is. Converts non-printable characters to strings like “\n” and “\x19”.
Uses
core::ascii::escape_default
(https://doc.rust-lang.org/core/ascii/fn.escape_default.html
internally to escape each byte.
This function is useful for printing byte slices to logs and comparing byte slices in tests.
Example test:
use fixed_buffer::FixedBuf;
let mut buf: FixedBuf<8> = FixedBuf::new();
buf.write_str("abc");
buf.write_str("€");
assert_eq!("abc\\xe2\\x82\\xac", buf.escape_ascii());
sourcepub fn mem(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn mem(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Borrows the entire internal memory buffer. This is a low-level function.
sourcepub fn readable(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn readable(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns the slice of readable bytes in the buffer.
After processing some bytes from the front of the slice,
call read
to consume the bytes.
This is a low-level method.
You probably want to use
std::io::Read::read
or
tokio::io::AsyncReadExt::read
, implemented for FixedBuffer in
fixed_buffer_tokio::AsyncReadExt
.
sourcepub fn read_byte(&mut self) -> u8
pub fn read_byte(&mut self) -> u8
Reads a single byte from the buffer.
Panics if the buffer is empty.
sourcepub fn try_read_byte(&mut self) -> Option<u8>
pub fn try_read_byte(&mut self) -> Option<u8>
Reads a single byte from the buffer.
Returns None
if the buffer is empty.
sourcepub fn read_bytes(&mut self, num_bytes: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn read_bytes(&mut self, num_bytes: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Reads bytes from the buffer.
Panics if the buffer does not contain enough bytes.
sourcepub fn try_read_bytes(&mut self, num_bytes: usize) -> Option<&[u8]>
pub fn try_read_bytes(&mut self, num_bytes: usize) -> Option<&[u8]>
Reads bytes from the buffer.
Returns None
if the buffer does not contain num_bytes
bytes.
sourcepub fn read_all(&mut self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn read_all(&mut self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Reads all the bytes from the buffer.
The buffer becomes empty and subsequent writes can fill the whole buffer.
sourcepub fn read_and_copy_bytes(&mut self, dest: &mut [u8]) -> usize
pub fn read_and_copy_bytes(&mut self, dest: &mut [u8]) -> usize
Reads bytes from the buffer and copies them into dest
.
Returns the number of bytes copied.
Returns 0
when the buffer is empty or dest
is zero-length.
sourcepub fn try_read_exact(&mut self, dest: &mut [u8]) -> Option<()>
pub fn try_read_exact(&mut self, dest: &mut [u8]) -> Option<()>
Reads byte from the buffer and copies them into dest
, filling it,
and returns ()
.
Returns None
if the buffer does not contain enough bytes tp fill dest
.
Returns ()
if dest
is zero-length.
sourcepub fn try_parse<R, F>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut FixedBuf<SIZE>) -> Option<R>,
pub fn try_parse<R, F>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut FixedBuf<SIZE>) -> Option<R>,
Try to parse the buffer contents with f
.
f
must return None
to indicate that the buffer
contains an incomplete data record.
When try_parse
returns None, the caller should add more data to the
buffer and call try_parse
again.
Undoes any reads that f
made to the buffer if it returns None
.
f
should not write to the buffer.
If f
writes to the buffer and then returns None
,
the buffer’s contents will become corrupted.
Example
#[derive(Debug)]
enum ReadError {
BufferFull,
EOF,
TooLong,
NotUtf8,
}
fn parse_record<const SIZE: usize>(buf: &mut FixedBuf<SIZE>)
-> Option<Result<String, ReadError>>
{
let len = buf.try_read_byte()? as usize;
if len > SIZE - 1 {
return Some(Err(ReadError::TooLong));
}
let bytes = buf.try_read_bytes(len)?.to_vec();
Some(String::from_utf8(bytes)
.map_err(|_| ReadError::NotUtf8))
}
let mut buf: FixedBuf<16> = FixedBuf::new();
loop {
// Try reading bytes into the buffer.
match read_input(&mut buf) {
Err(ReadError::EOF) if buf.is_empty() => break,
other => other?,
}
// Try parsing bytes into records.
loop {
if let Some(result) = buf.try_parse(parse_record) {
let record = result?;
process_record(record)?;
} else {
// Stop parsing and try reading more bytes.
break;
}
}
}
sourcepub fn copy_once_from<R>(&mut self, reader: &mut R) -> Result<usize, Error> where
R: Read,
pub fn copy_once_from<R>(&mut self, reader: &mut R) -> Result<usize, Error> where
R: Read,
Reads from reader
once and writes the data into the buffer.
Returns InvalidData
if there is no empty space in the buffer.
See shift
.
sourcepub fn write_str(&mut self, s: &str) -> Result<(), NotEnoughSpaceError>
pub fn write_str(&mut self, s: &str) -> Result<(), NotEnoughSpaceError>
Writes s
into the buffer, after any unread bytes.
Returns Err
if the buffer doesn’t have enough free space at the end
for the whole string.
See shift
.
Example:
let mut buf: FixedBuf<8> = FixedBuf::new();
buf.write_str("123").unwrap();
buf.write_str("456").unwrap();
assert_eq!("123456", buf.escape_ascii());
buf.write_str("78").unwrap();
buf.write_str("9").unwrap_err(); // End of buffer is full.
sourcepub fn write_bytes(&mut self, data: &[u8]) -> Result<usize, NotEnoughSpaceError>
pub fn write_bytes(&mut self, data: &[u8]) -> Result<usize, NotEnoughSpaceError>
Tries to write data
into the buffer, after any unread bytes.
Returns Ok(data.len())
if it wrote all of the bytes.
Returns NotEnoughSpaceError
if the buffer doesn’t have enough free space at the end for all of the bytes.
See shift
.
Example:
let mut buf: FixedBuf<8> = FixedBuf::new();
assert_eq!(3, buf.write_bytes("123".as_bytes()).unwrap());
assert_eq!(3, buf.write_bytes("456".as_bytes()).unwrap());
assert_eq!("123456", buf.escape_ascii());
assert_eq!(2, buf.write_bytes("78".as_bytes()).unwrap()); // Fills buffer.
buf.write_bytes("9".as_bytes()).unwrap_err(); // Error, buffer is full.
sourcepub fn writable(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn writable(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns the writable part of the buffer.
To use this, first modify bytes at the beginning of the slice.
Then call wrote(usize)
to commit those bytes into the buffer and make them available for reading.
Returns an empty slice when the end of the buffer is full.
See shift
.
This is a low-level method.
You probably want to use
std::io::Write::write
or
tokio::io::AsyncWriteExt::write
,
implemented for FixedBuffer in
fixed_buffer_tokio::AsyncWriteExt
.
Example:
let mut buf: FixedBuf<8> = FixedBuf::new();
buf.writable()[0] = 'a' as u8;
buf.writable()[1] = 'b' as u8;
buf.writable()[2] = 'c' as u8;
buf.wrote(3);
assert_eq!("abc", buf.escape_ascii());
sourcepub fn wrote(&mut self, num_bytes: usize)
pub fn wrote(&mut self, num_bytes: usize)
Commits bytes into the buffer.
Call this after writing to the front of the
writable
slice.
This is a low-level method.
Panics when there is not num_bytes
free at the end of the buffer.
See writable()
.
sourcepub fn shift(&mut self)
pub fn shift(&mut self)
Recovers buffer space.
The buffer is not circular. After you read bytes, the space at the beginning of the buffer is unused. Call this method to move unread data to the beginning of the buffer and recover the space. This makes the free space available for writes, which go at the end of the buffer.
sourcepub fn deframe<F>(
&mut self,
deframer_fn: F
) -> Result<Option<Range<usize>>, Error> where
F: Fn(&[u8]) -> Result<Option<(Range<usize>, usize)>, MalformedInputError>,
pub fn deframe<F>(
&mut self,
deframer_fn: F
) -> Result<Option<Range<usize>>, Error> where
F: Fn(&[u8]) -> Result<Option<(Range<usize>, usize)>, MalformedInputError>,
This is a low-level function.
Use read_frame
instead.
Calls deframer_fn
to check if the buffer contains a complete frame.
Consumes the frame bytes from the buffer
and returns the range of the frame’s contents in the internal memory.
Use mem
to immutably borrow the internal memory and
construct the slice with &buf.mem()[range]
.
This is necessary because deframe
borrows self
mutably but
read_frame
needs to borrow it immutably and return a slice.
Returns None
if the buffer is empty or contains an incomplete frame.
Returns InvalidData
when deframer_fn
returns an error.
sourcepub fn read_frame<R, F>(
&mut self,
reader: &mut R,
deframer_fn: F
) -> Result<Option<&[u8]>, Error> where
R: Read,
F: Fn(&[u8]) -> Result<Option<(Range<usize>, usize)>, MalformedInputError>,
pub fn read_frame<R, F>(
&mut self,
reader: &mut R,
deframer_fn: F
) -> Result<Option<&[u8]>, Error> where
R: Read,
F: Fn(&[u8]) -> Result<Option<(Range<usize>, usize)>, MalformedInputError>,
Reads from reader
into the buffer.
After each read, calls deframer_fn
to check if the buffer now contains a complete frame.
Consumes the frame bytes from the buffer
and returns a slice with the frame contents.
Returns None
when reader
reaches EOF and the buffer is empty.
Returns UnexpectedEof
when reader
reaches EOF and the buffer contains an incomplete frame.
Returns InvalidData
when deframer_fn
returns an error or the buffer fills up.
Calls shift
before reading.
Provided deframer functions:
Example
let mut buf: FixedBuf<32> = FixedBuf::new();
let mut input = std::io::Cursor::new(b"aaa\r\nbbb\n\nccc\n");
loop {
if let Some(line) =
buf.read_frame(&mut input, deframe_line).unwrap() {
println!("{}", escape_ascii(line));
} else {
// EOF.
break;
}
}
// Prints:
// aaa
// bbb
//
// ccc
Deframer Function deframe_fn
Checks if data
contains an entire frame.
Never panics.
Returns Err(MalformedInputError)
if data
contains a malformed frame.
Returns Ok(None)
if data
contains an incomplete frame.
The caller will read more data and call deframe
again.
Returns Ok((range, len))
when data
contains a complete well-formed
frame of length len
and contents &data[range]
.
A frame is a sequence of bytes containing a payload and metadata prefix or suffix bytes. The metadata define where the payload starts and ends. Popular frame protocols include line-delimiting (CSV), hexadecimal length prefix (HTTP chunked transfer encoding), and binary length prefix (TLS).
If the caller removes len
bytes from the front of data
, then
data
should start with the next frame, ready to call deframe
again.
A line-delimited deframer returns range
so that &data[range]
contains the entire line without the
final b'\n'
or b"\r\n"
.
It returns len
that counts the bytes of
the entire line and the final b'\n'
or b"\r\n"
.
Example
A CRLF-terminated line deframer:
assert_eq!(Ok(None), deframe_crlf(b""));
assert_eq!(Ok(None), deframe_crlf(b"abc"));
assert_eq!(Ok(None), deframe_crlf(b"abc\r"));
assert_eq!(Ok(None), deframe_crlf(b"abc\n"));
assert_eq!(Ok(Some((0..3, 5))), deframe_crlf(b"abc\r\n"));
assert_eq!(Ok(Some((0..3, 5))), deframe_crlf(b"abc\r\nX"));
Trait Implementations
sourceimpl<const SIZE: usize> AsyncRead for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> AsyncRead for AsyncFixedBuf<SIZE>
sourceimpl<const SIZE: usize> AsyncWrite for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> AsyncWrite for AsyncFixedBuf<SIZE>
sourcefn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>
fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>
Attempt to write bytes from buf
into the object. Read more
sourcefn poll_flush(
self: Pin<&mut Self>,
_cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_flush(
self: Pin<&mut Self>,
_cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
sourcefn poll_shutdown(
self: Pin<&mut Self>,
_cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
fn poll_shutdown(
self: Pin<&mut Self>,
_cx: &mut Context<'_>
) -> Poll<Result<(), Error>>
Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
sourcefn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
Like poll_write
, except that it writes from a slice of buffers. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Determines if this writer has an efficient poll_write_vectored
implementation. Read more
sourceimpl<const SIZE: usize> Deref for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> Deref for AsyncFixedBuf<SIZE>
sourceimpl<const SIZE: usize> DerefMut for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> DerefMut for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> Unpin for AsyncFixedBuf<SIZE>
Auto Trait Implementations
impl<const SIZE: usize> RefUnwindSafe for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> Send for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> Sync for AsyncFixedBuf<SIZE>
impl<const SIZE: usize> UnwindSafe for AsyncFixedBuf<SIZE>
Blanket Implementations
sourceimpl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
sourcefn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
Creates a new AsyncRead
instance that chains this stream with
next
. Read more
sourcefn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
Pulls some bytes from this source into the specified buffer, returning how many bytes were read. Read more
sourcefn read_buf<B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B> where
Self: Unpin,
B: BufMut,
fn read_buf<B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B> where
Self: Unpin,
B: BufMut,
Pulls some bytes from this source into the specified buffer, advancing the buffer’s internal cursor. Read more
sourcefn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
Reads the exact number of bytes required to fill buf
. Read more
sourcefn read_u8(&'a mut self) -> ReadU8<&'a mut Self> where
Self: Unpin,
fn read_u8(&'a mut self) -> ReadU8<&'a mut Self> where
Self: Unpin,
Reads an unsigned 8 bit integer from the underlying reader. Read more
sourcefn read_i8(&'a mut self) -> ReadI8<&'a mut Self> where
Self: Unpin,
fn read_i8(&'a mut self) -> ReadI8<&'a mut Self> where
Self: Unpin,
Reads a signed 8 bit integer from the underlying reader. Read more
sourcefn read_u16(&'a mut self) -> ReadU16<&'a mut Self> where
Self: Unpin,
fn read_u16(&'a mut self) -> ReadU16<&'a mut Self> where
Self: Unpin,
Reads an unsigned 16-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_i16(&'a mut self) -> ReadI16<&'a mut Self> where
Self: Unpin,
fn read_i16(&'a mut self) -> ReadI16<&'a mut Self> where
Self: Unpin,
Reads a signed 16-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_u32(&'a mut self) -> ReadU32<&'a mut Self> where
Self: Unpin,
fn read_u32(&'a mut self) -> ReadU32<&'a mut Self> where
Self: Unpin,
Reads an unsigned 32-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_i32(&'a mut self) -> ReadI32<&'a mut Self> where
Self: Unpin,
fn read_i32(&'a mut self) -> ReadI32<&'a mut Self> where
Self: Unpin,
Reads a signed 32-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_u64(&'a mut self) -> ReadU64<&'a mut Self> where
Self: Unpin,
fn read_u64(&'a mut self) -> ReadU64<&'a mut Self> where
Self: Unpin,
Reads an unsigned 64-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_i64(&'a mut self) -> ReadI64<&'a mut Self> where
Self: Unpin,
fn read_i64(&'a mut self) -> ReadI64<&'a mut Self> where
Self: Unpin,
Reads an signed 64-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_u128(&'a mut self) -> ReadU128<&'a mut Self> where
Self: Unpin,
fn read_u128(&'a mut self) -> ReadU128<&'a mut Self> where
Self: Unpin,
Reads an unsigned 128-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_i128(&'a mut self) -> ReadI128<&'a mut Self> where
Self: Unpin,
fn read_i128(&'a mut self) -> ReadI128<&'a mut Self> where
Self: Unpin,
Reads an signed 128-bit integer in big-endian order from the underlying reader. Read more
sourcefn read_f32(&'a mut self) -> ReadF32<&'a mut Self> where
Self: Unpin,
fn read_f32(&'a mut self) -> ReadF32<&'a mut Self> where
Self: Unpin,
Reads an 32-bit floating point type in big-endian order from the underlying reader. Read more
sourcefn read_f64(&'a mut self) -> ReadF64<&'a mut Self> where
Self: Unpin,
fn read_f64(&'a mut self) -> ReadF64<&'a mut Self> where
Self: Unpin,
Reads an 64-bit floating point type in big-endian order from the underlying reader. Read more
sourcefn read_u16_le(&'a mut self) -> ReadU16Le<&'a mut Self> where
Self: Unpin,
fn read_u16_le(&'a mut self) -> ReadU16Le<&'a mut Self> where
Self: Unpin,
Reads an unsigned 16-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_i16_le(&'a mut self) -> ReadI16Le<&'a mut Self> where
Self: Unpin,
fn read_i16_le(&'a mut self) -> ReadI16Le<&'a mut Self> where
Self: Unpin,
Reads a signed 16-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_u32_le(&'a mut self) -> ReadU32Le<&'a mut Self> where
Self: Unpin,
fn read_u32_le(&'a mut self) -> ReadU32Le<&'a mut Self> where
Self: Unpin,
Reads an unsigned 32-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_i32_le(&'a mut self) -> ReadI32Le<&'a mut Self> where
Self: Unpin,
fn read_i32_le(&'a mut self) -> ReadI32Le<&'a mut Self> where
Self: Unpin,
Reads a signed 32-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_u64_le(&'a mut self) -> ReadU64Le<&'a mut Self> where
Self: Unpin,
fn read_u64_le(&'a mut self) -> ReadU64Le<&'a mut Self> where
Self: Unpin,
Reads an unsigned 64-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_i64_le(&'a mut self) -> ReadI64Le<&'a mut Self> where
Self: Unpin,
fn read_i64_le(&'a mut self) -> ReadI64Le<&'a mut Self> where
Self: Unpin,
Reads an signed 64-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_u128_le(&'a mut self) -> ReadU128Le<&'a mut Self> where
Self: Unpin,
fn read_u128_le(&'a mut self) -> ReadU128Le<&'a mut Self> where
Self: Unpin,
Reads an unsigned 128-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_i128_le(&'a mut self) -> ReadI128Le<&'a mut Self> where
Self: Unpin,
fn read_i128_le(&'a mut self) -> ReadI128Le<&'a mut Self> where
Self: Unpin,
Reads an signed 128-bit integer in little-endian order from the underlying reader. Read more
sourcefn read_f32_le(&'a mut self) -> ReadF32Le<&'a mut Self> where
Self: Unpin,
fn read_f32_le(&'a mut self) -> ReadF32Le<&'a mut Self> where
Self: Unpin,
Reads an 32-bit floating point type in little-endian order from the underlying reader. Read more
sourcefn read_f64_le(&'a mut self) -> ReadF64Le<&'a mut Self> where
Self: Unpin,
fn read_f64_le(&'a mut self) -> ReadF64Le<&'a mut Self> where
Self: Unpin,
Reads an 64-bit floating point type in little-endian order from the underlying reader. Read more
sourcefn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
Reads all bytes until EOF in this source, placing them into buf
. Read more
sourcefn read_to_string(&'a mut self, dst: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
fn read_to_string(&'a mut self, dst: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
Reads all bytes until EOF in this source, appending them to buf
. Read more
sourceimpl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
sourcefn write(&'a mut self, src: &'a [u8]) -> Write<'a, Self> where
Self: Unpin,
fn write(&'a mut self, src: &'a [u8]) -> Write<'a, Self> where
Self: Unpin,
Writes a buffer into this writer, returning how many bytes were written. Read more
sourcefn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'b>]
) -> WriteVectored<'a, 'b, Self> where
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'b>]
) -> WriteVectored<'a, 'b, Self> where
Self: Unpin,
sourcefn write_buf<B>(&'a mut self, src: &'a mut B) -> WriteBuf<'a, Self, B> where
Self: Unpin,
B: Buf,
fn write_buf<B>(&'a mut self, src: &'a mut B) -> WriteBuf<'a, Self, B> where
Self: Unpin,
B: Buf,
Writes a buffer into this writer, advancing the buffer’s internal cursor. Read more
sourcefn write_all_buf<B>(&'a mut self, src: &'a mut B) -> WriteAllBuf<'a, Self, B> where
Self: Unpin,
B: Buf,
fn write_all_buf<B>(&'a mut self, src: &'a mut B) -> WriteAllBuf<'a, Self, B> where
Self: Unpin,
B: Buf,
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all(&'a mut self, src: &'a [u8]) -> WriteAll<'a, Self> where
Self: Unpin,
fn write_all(&'a mut self, src: &'a [u8]) -> WriteAll<'a, Self> where
Self: Unpin,
Attempts to write an entire buffer into this writer. Read more
sourcefn write_u8(&'a mut self, n: u8) -> WriteU8<&'a mut Self> where
Self: Unpin,
fn write_u8(&'a mut self, n: u8) -> WriteU8<&'a mut Self> where
Self: Unpin,
Writes an unsigned 8-bit integer to the underlying writer. Read more
sourcefn write_i8(&'a mut self, n: i8) -> WriteI8<&'a mut Self> where
Self: Unpin,
fn write_i8(&'a mut self, n: i8) -> WriteI8<&'a mut Self> where
Self: Unpin,
Writes an unsigned 8-bit integer to the underlying writer. Read more
sourcefn write_u16(&'a mut self, n: u16) -> WriteU16<&'a mut Self> where
Self: Unpin,
fn write_u16(&'a mut self, n: u16) -> WriteU16<&'a mut Self> where
Self: Unpin,
Writes an unsigned 16-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_i16(&'a mut self, n: i16) -> WriteI16<&'a mut Self> where
Self: Unpin,
fn write_i16(&'a mut self, n: i16) -> WriteI16<&'a mut Self> where
Self: Unpin,
Writes a signed 16-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_u32(&'a mut self, n: u32) -> WriteU32<&'a mut Self> where
Self: Unpin,
fn write_u32(&'a mut self, n: u32) -> WriteU32<&'a mut Self> where
Self: Unpin,
Writes an unsigned 32-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_i32(&'a mut self, n: i32) -> WriteI32<&'a mut Self> where
Self: Unpin,
fn write_i32(&'a mut self, n: i32) -> WriteI32<&'a mut Self> where
Self: Unpin,
Writes a signed 32-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_u64(&'a mut self, n: u64) -> WriteU64<&'a mut Self> where
Self: Unpin,
fn write_u64(&'a mut self, n: u64) -> WriteU64<&'a mut Self> where
Self: Unpin,
Writes an unsigned 64-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_i64(&'a mut self, n: i64) -> WriteI64<&'a mut Self> where
Self: Unpin,
fn write_i64(&'a mut self, n: i64) -> WriteI64<&'a mut Self> where
Self: Unpin,
Writes an signed 64-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_u128(&'a mut self, n: u128) -> WriteU128<&'a mut Self> where
Self: Unpin,
fn write_u128(&'a mut self, n: u128) -> WriteU128<&'a mut Self> where
Self: Unpin,
Writes an unsigned 128-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_i128(&'a mut self, n: i128) -> WriteI128<&'a mut Self> where
Self: Unpin,
fn write_i128(&'a mut self, n: i128) -> WriteI128<&'a mut Self> where
Self: Unpin,
Writes an signed 128-bit integer in big-endian order to the underlying writer. Read more
sourcefn write_f32(&'a mut self, n: f32) -> WriteF32<&'a mut Self> where
Self: Unpin,
fn write_f32(&'a mut self, n: f32) -> WriteF32<&'a mut Self> where
Self: Unpin,
Writes an 32-bit floating point type in big-endian order to the underlying writer. Read more
sourcefn write_f64(&'a mut self, n: f64) -> WriteF64<&'a mut Self> where
Self: Unpin,
fn write_f64(&'a mut self, n: f64) -> WriteF64<&'a mut Self> where
Self: Unpin,
Writes an 64-bit floating point type in big-endian order to the underlying writer. Read more
sourcefn write_u16_le(&'a mut self, n: u16) -> WriteU16Le<&'a mut Self> where
Self: Unpin,
fn write_u16_le(&'a mut self, n: u16) -> WriteU16Le<&'a mut Self> where
Self: Unpin,
Writes an unsigned 16-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_i16_le(&'a mut self, n: i16) -> WriteI16Le<&'a mut Self> where
Self: Unpin,
fn write_i16_le(&'a mut self, n: i16) -> WriteI16Le<&'a mut Self> where
Self: Unpin,
Writes a signed 16-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_u32_le(&'a mut self, n: u32) -> WriteU32Le<&'a mut Self> where
Self: Unpin,
fn write_u32_le(&'a mut self, n: u32) -> WriteU32Le<&'a mut Self> where
Self: Unpin,
Writes an unsigned 32-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_i32_le(&'a mut self, n: i32) -> WriteI32Le<&'a mut Self> where
Self: Unpin,
fn write_i32_le(&'a mut self, n: i32) -> WriteI32Le<&'a mut Self> where
Self: Unpin,
Writes a signed 32-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_u64_le(&'a mut self, n: u64) -> WriteU64Le<&'a mut Self> where
Self: Unpin,
fn write_u64_le(&'a mut self, n: u64) -> WriteU64Le<&'a mut Self> where
Self: Unpin,
Writes an unsigned 64-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_i64_le(&'a mut self, n: i64) -> WriteI64Le<&'a mut Self> where
Self: Unpin,
fn write_i64_le(&'a mut self, n: i64) -> WriteI64Le<&'a mut Self> where
Self: Unpin,
Writes an signed 64-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_u128_le(&'a mut self, n: u128) -> WriteU128Le<&'a mut Self> where
Self: Unpin,
fn write_u128_le(&'a mut self, n: u128) -> WriteU128Le<&'a mut Self> where
Self: Unpin,
Writes an unsigned 128-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_i128_le(&'a mut self, n: i128) -> WriteI128Le<&'a mut Self> where
Self: Unpin,
fn write_i128_le(&'a mut self, n: i128) -> WriteI128Le<&'a mut Self> where
Self: Unpin,
Writes an signed 128-bit integer in little-endian order to the underlying writer. Read more
sourcefn write_f32_le(&'a mut self, n: f32) -> WriteF32Le<&'a mut Self> where
Self: Unpin,
fn write_f32_le(&'a mut self, n: f32) -> WriteF32Le<&'a mut Self> where
Self: Unpin,
Writes an 32-bit floating point type in little-endian order to the underlying writer. Read more
sourcefn write_f64_le(&'a mut self, n: f64) -> WriteF64Le<&'a mut Self> where
Self: Unpin,
fn write_f64_le(&'a mut self, n: f64) -> WriteF64Le<&'a mut Self> where
Self: Unpin,
Writes an 64-bit floating point type in little-endian order to the underlying writer. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more