Struct BufWriter

Source
pub struct BufWriter<W> { /* private fields */ }
Expand description

BufWriter is a struct with a buffer. BufWriter implements AsyncWriteRent, and if the inner io implements AsyncReadRent, it will delegate the implementation.

Implementations§

Source§

impl<W> BufWriter<W>

Source

pub fn new(inner: W) -> Self

Create BufWriter with default buffer size

Source

pub fn with_capacity(capacity: usize, inner: W) -> Self

Create BufWriter with given buffer size

Source

pub fn get_ref(&self) -> &W

Gets a reference to the underlying writer.

Source

pub fn get_mut(&mut self) -> &mut W

Gets a mutable reference to the underlying writer.

Source

pub fn into_inner(self) -> W

Consumes this BufWriter, returning the underlying writer.

Note that any leftover data in the internal buffer is lost.

Source

pub fn buffer(&self) -> &[u8]

Returns a reference to the internally buffered data.

Trait Implementations§

Source§

impl<W: AsyncWriteRent + AsyncBufRead> AsyncBufRead for BufWriter<W>

Source§

fn fill_buf(&mut self) -> impl Future<Output = Result<&[u8]>>

Try read data and get a reference to the internal buffer
Source§

fn consume(&mut self, amt: usize)

Mark how much data is read
Source§

impl<W: AsyncWriteRent + AsyncReadRent> AsyncReadRent for BufWriter<W>

Source§

fn read<T: IoBufMut>( &mut self, buf: T, ) -> impl Future<Output = BufResult<usize, T>>

Reads bytes from this source into the provided buffer, returning the number of bytes read. Read more
Source§

fn readv<T: IoVecBufMut>( &mut self, buf: T, ) -> impl Future<Output = BufResult<usize, T>>

Similar to read, but reads data into a slice of buffers. Read more
Source§

impl<W: AsyncWriteRent> AsyncWriteRent for BufWriter<W>

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Writes the contents of a buffer into this writer, returning the number of bytes written. Read more
Source§

async fn writev<T: IoVecBuf>(&mut self, buf: T) -> BufResult<usize, T>

This function attempts to write the entire contents of buf_vec, but the write may not fully succeed, and it might also result in an error. The bytes will be written starting at the specified offset. Read more
Source§

async fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all buffered content is successfully written to its destination. Read more
Source§

async fn shutdown(&mut self) -> Result<()>

Shuts down the output stream, ensuring that the value can be cleanly dropped. Read more

Auto Trait Implementations§

§

impl<W> Freeze for BufWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for BufWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for BufWriter<W>
where W: Send,

§

impl<W> Sync for BufWriter<W>
where W: Sync,

§

impl<W> Unpin for BufWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for BufWriter<W>
where W: 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<A> AsyncBufReadExt for A
where A: AsyncBufRead + ?Sized,

Source§

fn read_until<'a>( &'a mut self, byte: u8, buf: &'a mut Vec<u8>, ) -> impl Future<Output = Result<usize, Error>>

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

async fn read_line<'a>( &'a mut self, buf: &'a mut String, ) -> Result<usize, Error>

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

impl<A> AsyncReadRentExt for A
where A: AsyncReadRent + ?Sized,

Source§

async fn read_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoBufMut + 'static,

Read until buf capacity is fulfilled
Source§

async fn read_vectored_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoVecBufMut + 'static,

Readv until buf capacity is fulfilled
Source§

async fn read_u8(&mut self) -> Result<u8, Error>

Read number in async way
Source§

async fn read_u16(&mut self) -> Result<u16, Error>

Read number in async way
Source§

async fn read_u32(&mut self) -> Result<u32, Error>

Read number in async way
Source§

async fn read_u64(&mut self) -> Result<u64, Error>

Read number in async way
Source§

async fn read_u128(&mut self) -> Result<u16, Error>

Read number in async way
Source§

async fn read_i8(&mut self) -> Result<i8, Error>

Read number in async way
Source§

async fn read_i16(&mut self) -> Result<i16, Error>

Read number in async way
Source§

async fn read_i32(&mut self) -> Result<i32, Error>

Read number in async way
Source§

async fn read_i64(&mut self) -> Result<i64, Error>

Read number in async way
Source§

async fn read_i128(&mut self) -> Result<i128, Error>

Read number in async way
Source§

async fn read_f32(&mut self) -> Result<f32, Error>

Read number in async way
Source§

async fn read_f64(&mut self) -> Result<f64, Error>

Read number in async way
Source§

async fn read_u8_le(&mut self) -> Result<u8, Error>

Read number in async way
Source§

async fn read_u16_le(&mut self) -> Result<u16, Error>

Read number in async way
Source§

async fn read_u32_le(&mut self) -> Result<u32, Error>

Read number in async way
Source§

async fn read_u64_le(&mut self) -> Result<u64, Error>

Read number in async way
Source§

async fn read_u128_le(&mut self) -> Result<u128, Error>

Read number in async way
Source§

async fn read_i8_le(&mut self) -> Result<i8, Error>

Read number in async way
Source§

async fn read_i16_le(&mut self) -> Result<i16, Error>

Read number in async way
Source§

async fn read_i32_le(&mut self) -> Result<i32, Error>

Read number in async way
Source§

async fn read_i64_le(&mut self) -> Result<i64, Error>

Read number in async way
Source§

async fn read_i128_le(&mut self) -> Result<i128, Error>

Read number in async way
Source§

async fn read_f32_le(&mut self) -> Result<f32, Error>

Read number in async way
Source§

async fn read_f64_le(&mut self) -> Result<f64, Error>

Read number in async way
Source§

impl<A> AsyncWriteRentExt for A
where A: AsyncWriteRent + ?Sized,

Source§

async fn write_all<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoBuf + 'static,

Write all
Source§

async fn write_vectored_all<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoVecBuf + 'static,

Write vectored all
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.