IoSlices

Struct IoSlices 

Source
pub struct IoSlices<'a> {
    pub slots: Vec<SliceSlot<'a>>,
}
Expand description

A collection of vectored I/O slices used for efficient streaming writes.

Internally maintains a list of SliceSlots, which can be borrowed or owned. Provides utilities to build and write the combined data.

Fields§

§slots: Vec<SliceSlot<'a>>

Internal list of slices to be written.

Implementations§

Source§

impl<'a> IoSlices<'a>

Source

pub fn add_slice(&mut self, buf: &'a [u8])

Adds a borrowed slice to the buffer.

§Arguments
  • buf – A borrowed slice (&[u8]) to be written.
Source

pub fn add_buffered(&mut self, buf: Vec<u8>)

Adds an owned buffer to the buffer list.

§Arguments
  • buf – A Vec<u8> to be owned and written.
Source

pub fn get(&self) -> Vec<IoSlice<'_>>

Converts all internal slots into a Vec<IoSlice> for writing.

This method is non-destructive and safe to call multiple times.

§Returns

A vector of std::io::IoSlice values ready for write_vectored.

Source

pub fn append(&mut self, another: IoSlices<'a>)

Appends another IoSlices into this one, consuming the other buffer.

§Arguments
  • another – Another IoSlices instance to merge into this one.
Source

pub fn write_vectored_all<T: Write>(&self, buf: &mut T) -> Result<()>

Writes all buffers to the given stream using vectored I/O.

Handles partial writes and retries until all slices are written.

§Arguments
  • buf – A writable output stream.
§Errors

Returns an error if the write operation fails or stalls (WriteZero).

Trait Implementations§

Source§

impl<'a> Default for IoSlices<'a>

Source§

fn default() -> IoSlices<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for IoSlices<'a>

§

impl<'a> RefUnwindSafe for IoSlices<'a>

§

impl<'a> Send for IoSlices<'a>

§

impl<'a> Sync for IoSlices<'a>

§

impl<'a> Unpin for IoSlices<'a>

§

impl<'a> UnwindSafe for IoSlices<'a>

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 = 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.