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
impl CompressReserveBehavior
Sourcepub fn current_buf(&mut self) -> Option<&mut Vec<u8>>
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§
impl Freeze for CompressReserveBehavior
impl RefUnwindSafe for CompressReserveBehavior
impl Send for CompressReserveBehavior
impl Sync for CompressReserveBehavior
impl Unpin for CompressReserveBehavior
impl UnwindSafe for CompressReserveBehavior
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more