AbiBuffer

Struct AbiBuffer 

Source
pub struct AbiBuffer<T: 'static> { /* private fields */ }
Expand description

A helper structure used with a stream to handle the canonical ABI representation of lists and track partial writes.

This structure is returned whenever a write to a stream completes. This keeps track of the original buffer used to perform a write (Vec<T>) and additionally tracks any partial writes. Writes can then be resumed with this buffer again or the partial write can be converted back to Vec<T> to get access to the remaining values.

This value is created through the StreamWrite future’s return value.

Implementations§

Source§

impl<T: 'static> AbiBuffer<T>

Source

pub fn into_vec(self) -> Vec<T>

Converts this AbiBuffer<T> back into a Vec<T>

This commit consumes this buffer and yields back unwritten values as a Vec<T>. The remaining items in Vec<T> have not yet been written and all written items have been removed from the front of the list.

Note that the backing storage of the returned Vec<T> has not changed from whe this buffer was created.

Also note that this can be an expensive operation if a partial write occurred as this will involve shifting items from the end of the vector to the start of the vector.

Source

pub fn remaining(&self) -> usize

Returns the number of items remaining in this buffer.

Trait Implementations§

Source§

impl<T> Drop for AbiBuffer<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AbiBuffer<T>

§

impl<T> RefUnwindSafe for AbiBuffer<T>
where T: RefUnwindSafe,

§

impl<T> Send for AbiBuffer<T>
where T: Send,

§

impl<T> Sync for AbiBuffer<T>
where T: Sync,

§

impl<T> Unpin for AbiBuffer<T>
where T: Unpin,

§

impl<T> UnwindSafe for AbiBuffer<T>
where T: 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 = 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.