sonic_rs::writer

Trait WriteExt

Source
pub trait WriteExt: Write {
    // Required methods
    fn reserve_with(
        &mut self,
        additional: usize,
    ) -> Result<&mut [MaybeUninit<u8>]>;
    unsafe fn flush_len(&mut self, additional: usize);
}
Expand description

The trait is a extension to io::Write with a reserved capacity.

Required Methods§

Source

fn reserve_with(&mut self, additional: usize) -> Result<&mut [MaybeUninit<u8>]>

Reserve with additional capacity and returns the remaining spare capacity of the write as a slice of MaybeUninit<u8>.

The returned slice will be used to write new data before marking the data as initialized using the WriteExt::flush_len method.

Source

unsafe fn flush_len(&mut self, additional: usize)

Flush the additional length to the output stream, ensuring that additional bytes intermediately buffered contents reach their destination.

§Safety

Must be used after reserve_with

Implementations on Foreign Types§

Source§

impl WriteExt for Vec<u8>

Source§

fn reserve_with(&mut self, additional: usize) -> Result<&mut [MaybeUninit<u8>]>

Source§

unsafe fn flush_len(&mut self, additional: usize)

Source§

impl WriteExt for Writer<BytesMut>

Source§

unsafe fn flush_len(&mut self, additional: usize)

Source§

fn reserve_with(&mut self, additional: usize) -> Result<&mut [MaybeUninit<u8>]>

Source§

impl<W: WriteExt + ?Sized> WriteExt for &mut W

Source§

unsafe fn flush_len(&mut self, additional: usize)

Source§

fn reserve_with(&mut self, additional: usize) -> Result<&mut [MaybeUninit<u8>]>

Source§

impl<W: WriteExt + ?Sized> WriteExt for Box<W>

Source§

unsafe fn flush_len(&mut self, additional: usize)

Source§

fn reserve_with(&mut self, additional: usize) -> Result<&mut [MaybeUninit<u8>]>

Source§

impl<W: WriteExt + ?Sized> WriteExt for BufWriter<W>

Source§

fn reserve_with(&mut self, additional: usize) -> Result<&mut [MaybeUninit<u8>]>

Source§

unsafe fn flush_len(&mut self, additional: usize)

Implementors§