gix_utils

Struct Buffers

source
pub struct Buffers {
    pub src: Vec<u8>,
    pub dest: Vec<u8>,
}
Expand description

A utility to do buffer-swapping with.

Use src to read from and dest to write to, and after actually changing data, call Buffers::swap(). To be able to repeat the process, this time using what was dest as src, freeing up dest for writing once more.

Note that after each Buffers::swap(), src is the most recent version of the data, just like before each swap.

Fields§

§src: Vec<u8>

The source data, as basis for processing.

§dest: Vec<u8>

The data produced after processing src.

Implementations§

source§

impl Buffers

Lifecycle

source

pub fn use_foreign_src<'a, 'src>( &'a mut self, src: &'src [u8], ) -> WithForeignSource<'src, 'a>

Use this if there is an input buffer src which isn’t owned by you, but which should be used as source when asking for src_and_dest().

source§

impl Buffers

source

pub fn clear(&mut self)

Clear all buffers, which should be called once processing is done.

source

pub fn swap(&mut self)

Must be called after every change (i.e. when it’s known that dest was written.

Trait Implementations§

source§

impl Clone for Buffers

source§

fn clone(&self) -> Buffers

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Buffers

source§

fn default() -> Buffers

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

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.