Struct zstd_safe::OutBuffer

source ·
pub struct OutBuffer<'a, C: WriteBuf + ?Sized> {
    pub dst: &'a mut C,
    /* private fields */
}
Expand description

Wrapper around an output buffer.

C is usually either [u8] or Vec<u8>.

Bytes will be written starting at dst[pos].

pos will be updated after writing.

§Invariant

pos <= dst.capacity()

Fields§

§dst: &'a mut C

Implementations§

source§

impl<'a, C: WriteBuf + ?Sized> OutBuffer<'a, C>

source

pub fn around(dst: &'a mut C) -> Self

Returns a new OutBuffer around the given slice.

Starts with pos = 0.

source

pub fn around_pos(dst: &'a mut C, pos: usize) -> Self

Returns a new OutBuffer around the given slice, starting at the given position.

§Panics

If pos >= dst.capacity().

source

pub fn pos(&self) -> usize

Returns the current cursor position.

source

pub unsafe fn set_pos(&mut self, pos: usize)

Sets the new cursor position.

§Panics

If pos > self.dst.capacity().

§Safety

Data up to pos must have actually been written to.

source

pub fn as_slice<'b>(&'b self) -> &'a [u8]
where 'b: 'a,

Returns the part of this buffer that was written to.

Trait Implementations§

source§

impl<'a, C: Debug + WriteBuf + ?Sized> Debug for OutBuffer<'a, C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, C> Freeze for OutBuffer<'a, C>
where C: ?Sized,

§

impl<'a, C> RefUnwindSafe for OutBuffer<'a, C>
where C: RefUnwindSafe + ?Sized,

§

impl<'a, C> Send for OutBuffer<'a, C>
where C: Send + ?Sized,

§

impl<'a, C> Sync for OutBuffer<'a, C>
where C: Sync + ?Sized,

§

impl<'a, C> Unpin for OutBuffer<'a, C>
where C: ?Sized,

§

impl<'a, C> !UnwindSafe for OutBuffer<'a, C>

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

§

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.