Destination

Trait Destination 

Source
pub unsafe trait Destination {
    type Output;

    // Required methods
    fn capacity(&self) -> usize;
    fn as_mut_ptr(&mut self) -> *mut u8;
    unsafe fn finish(self, size: usize) -> Self::Output;
}
Expand description

Destination buffer usable as a compression and decompression target.

§Safety

The as_mut_ptr method must return a valid pointer to a start of a possibly uninitialized but valid to write to slice with a minimum size of Self::capacity(). The return value of the capacity function therefore also has to be accurate in order to prevent out of memory writes. Even though the finish method is expected to be called at some point but cannot be relied on.

Required Associated Types§

Required Methods§

Source

fn capacity(&self) -> usize

Source

fn as_mut_ptr(&mut self) -> *mut u8

Source

unsafe fn finish(self, size: usize) -> Self::Output

Mark the output buffer as complete and return the final safe output.

§Safety

The caller is required to have at least written the first size bytes to the contiguous slice backed by the pointer returned by as_mut_ptr.

Implementations on Foreign Types§

Source§

impl Destination for &mut Vec<u8>

Source§

type Output = ()

Source§

fn capacity(&self) -> usize

Source§

fn as_mut_ptr(&mut self) -> *mut u8

Source§

unsafe fn finish(self, size: usize) -> Self::Output

Source§

impl Destination for Vec<u8>

Source§

type Output = Vec<u8>

Source§

fn capacity(&self) -> usize

Source§

fn as_mut_ptr(&mut self) -> *mut u8

Source§

unsafe fn finish(self, size: usize) -> Self::Output

Source§

impl<'a> Destination for &'a mut [u8]

Source§

type Output = &'a mut [u8]

Source§

fn capacity(&self) -> usize

Source§

fn as_mut_ptr(&mut self) -> *mut u8

Source§

unsafe fn finish(self, size: usize) -> Self::Output

Implementors§