Struct allsorts::binary::write::WriteBuffer

source ·
pub struct WriteBuffer { /* private fields */ }
Expand description

An in-memory buffer that implements WriteContext.

Implementations§

source§

impl WriteBuffer

source

pub fn new() -> Self

Create a new, empty WriteBuffer

source

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

Retrieve a slice of the data held by this buffer

source

pub fn clear(&mut self)

Clear the internal data so that this buffer can be reused

source

pub fn len(&self) -> usize

Returns the current size of the data held by this buffer

source

pub fn into_inner(self) -> Vec<u8>

Consume self and return the inner buffer

Trait Implementations§

source§

impl WriteContext for WriteBuffer

source§

fn write_bytes(&mut self, data: &[u8]) -> Result<(), WriteError>

Write a slice of bytes to a WriteContext.
source§

fn write_zeros(&mut self, count: usize) -> Result<(), WriteError>

Write the specified number of zero bytes to the WriteContext.
source§

fn bytes_written(&self) -> usize

The total number of bytes written so far.
source§

fn write_placeholder<T, HostType>( &mut self, placeholder: Placeholder<T, HostType>, val: HostType, ) -> Result<T::Output, WriteError>
where T: WriteBinary<HostType>,

Consumes the placeholder and writes the supplied value into it
source§

fn write_placeholder_dep<T, HostType>( &mut self, placeholder: Placeholder<T, HostType>, val: HostType, args: T::Args, ) -> Result<T::Output, WriteError>
where T: WriteBinaryDep<HostType>,

Consumes the placeholder and writes the supplied value into it. WriteBinaryDep version
source§

fn write_array<'a, T>( &mut self, array: &ReadArray<'a, T>, ) -> Result<(), WriteError>

Write a ReadArray instance to a WriteContext.
source§

fn write_vec<T, HostType>( &mut self, vec: Vec<HostType>, ) -> Result<(), WriteError>
where Self: Sized, T: WriteBinary<HostType>,

Write a Vec into a WriteContext.
source§

fn write_iter<T, HostType>( &mut self, iter: impl Iterator<Item = HostType>, ) -> Result<(), WriteError>
where Self: Sized, T: WriteBinary<HostType>,

Write a slice of values into a WriteContext.
source§

fn placeholder<'a, T, HostType>( &mut self, ) -> Result<Placeholder<T, HostType>, WriteError>
where T: WriteBinary<HostType> + ReadUnchecked,

Return a placeholder to T in the context for filling in later.
source§

fn reserve<'a, T, HostType>( &mut self, count: usize, ) -> Result<Placeholder<T, &'a HostType>, WriteError>

Reserve space for count bytes in the context for filling in later.
source§

fn placeholder_array<'a, T, HostType>( &mut self, count: usize, ) -> Result<Vec<Placeholder<T, HostType>>, WriteError>
where T: WriteBinary<HostType> + ReadUnchecked,

Return a Vec of count placeholders of type T.

Auto Trait Implementations§

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.