Struct SnapBuf

Source
pub struct SnapBuf { /* private fields */ }

Implementations§

Source§

impl SnapBuf

Source

pub fn new() -> Self

Creates an empty buffer.

Source

pub fn resize_zero(&mut self, new_len: usize)

Resizes the buffer, so that len == new_len.

If new_len is greater than len, the new space in the buffer is filled with zeros.

Source

pub fn write(&mut self, offset: usize, data: &[u8])

Writes data at the specified offset.

If this extends past the current end of the buffer, the buffer is automatically resized. If offset is larger than the current buffer length, the space between the current buffer end and the written region is filled with zeros.

Source

pub fn is_empty(&self) -> bool

Returns true if the buffer length is zero.

Source

pub fn len(&self) -> usize

Returns the length of the buffer, the number of bytes it contains.

The memory footprint of the buffer may be much smaller than this due to omission of zero segments and sharing with other buffers.

Source

pub fn clear_range(&mut self, range: Range<usize>)

Clears data in range, possibly freeing memory.

§Panics

Panics if range end is range.end > self.len().

Source

pub fn clear(&mut self)

Clears all data and sets length to 0.

Source

pub fn chunks(&self) -> impl Iterator<Item = &[u8]>

Returns an iterator over the byte slices constituting the buffer.

The returned slices may overlap.

Source

pub fn iter(&self) -> impl Iterator<Item = &u8>

Returns an iterator over the buffer.

Trait Implementations§

Source§

impl Debug for SnapBuf

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SnapBuf

Source§

fn default() -> Self

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