pub trait AsyncBufReadExt {
// Required methods
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> impl Future<Output = Result<usize>>;
fn read_line<'a>(
&'a mut self,
buf: &'a mut String,
) -> impl Future<Output = Result<usize>>;
}
Expand description
AsyncBufReadExt
Required Methods§
Sourcefn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> impl Future<Output = Result<usize>>
fn read_until<'a>( &'a mut self, byte: u8, buf: &'a mut Vec<u8>, ) -> impl Future<Output = Result<usize>>
This function will read bytes from the underlying stream until the delimiter or EOF is found. Once found, all bytes up to, and including, the delimiter (if found) will be appended to buf.
If successful, this function will return the total number of bytes read.
§Errors
This function will ignore all instances of ErrorKind::Interrupted and will otherwise return any errors returned by fill_buf.
Sourcefn read_line<'a>(
&'a mut self,
buf: &'a mut String,
) -> impl Future<Output = Result<usize>>
fn read_line<'a>( &'a mut self, buf: &'a mut String, ) -> impl Future<Output = Result<usize>>
This function will read bytes from the underlying stream until the newline delimiter (the 0xA byte) or EOF is found. Once found, all bytes up to, and including, the delimiter (if found) will be appended to buf.
If successful, this function will return the total number of bytes read.
If this function returns Ok(0), the stream has reached EOF.
§Errors
This function has the same error semantics as read_until and will also return an error if the read bytes are not valid UTF-8. If an I/O error is encountered then buf may contain some bytes already read in the event that all data read so far was valid UTF-8.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.