Enum CompressReserveBehavior

Source
pub enum CompressReserveBehavior {
    NewBuf,
    ExpandBuf(Vec<u8>),
    FixedSizeBuf(Vec<u8>),
}
Available on crate feature stream only.
Expand description

How to allocate the buffer in CompressedStream::compress().

Variants§

§

NewBuf

Allocate a new buffer of the appropriate size.

§

ExpandBuf(Vec<u8>)

Re-use the given buffer, but expand its size by reallocating if needed.

§

FixedSizeBuf(Vec<u8>)

Re-use the given buffer, and raise an error if reallocation is necessary.

Implementations§

Source§

impl CompressReserveBehavior

Source

pub fn current_buf(&mut self) -> Option<&mut Vec<u8>>

Get a mutable reference to the existing buffer contents, if available.

The contents can be moved out of the resulting mutable vector with e.g. mem::take():

 use vectorscan::stream::CompressReserveBehavior;
 use std::mem;

 let mut buf = CompressReserveBehavior::NewBuf;
 assert!(buf.current_buf().is_none());
 buf = CompressReserveBehavior::FixedSizeBuf(vec![0; 32]);
 let b = mem::take(buf.current_buf().unwrap());
 assert_eq!(buf.current_buf(), Some(&mut vec![]));
 assert_eq!(b, vec![0; 32]);

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.