Skip to main content

DefaultBuffer

Struct DefaultBuffer 

Source
pub struct DefaultBuffer<W: Write> { /* private fields */ }
Expand description

A BufWriter-like type that exposes its unfilled capacity as a slice through BufferedWrite trait.

Like BufWriter, this structure stores the written bytes in its internal buffer and writes them into the underlying writer when dropped or when the buffer becomes full.

Implementations§

Source§

impl<W: Write> DefaultBuffer<W>

Source

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

Returns a reference to the unwritten buffered data.

Source

pub fn get_ref(&self) -> &W

Returns a reference to the underlying writer.

Source

pub fn into_parts(self) -> (W, Result<Vec<u8>, WriterPanicked>)

Disassembles the structure and returns the underlying writer and unwritten buffered data.

If the underlying writer experienced panic in a previous call to write, this method wraps the buffered data with the WriterPanicked error to signal the fact that the buffered data might have been partly written to the underlying writer.

This method does not attempt to flush the buffer.

Trait Implementations§

Source§

impl<W: Write> BufferedWrite for DefaultBuffer<W>

Source§

fn unfilled(&mut self) -> &mut [u8] ⓘ

Returns the unfilled buffer capacity as a slice. Read more
Source§

fn advance(&mut self, n: usize)

Marks the first n bytes of the unfilled buffer as filled. Read more
Source§

fn try_reserve( &mut self, minimum: usize, size_hint: Option<usize>, ) -> Result<()>

Tries to reserve capacity for at least minimum more bytes. Read more
Source§

impl<W: Debug + Write> Debug for DefaultBuffer<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W: Write> Drop for DefaultBuffer<W>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<W: Write> Write for DefaultBuffer<W>

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

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

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<W> UnsafeUnpin for DefaultBuffer<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for DefaultBuffer<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<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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.