Skip to main content

BroCatli

Struct BroCatli 

Source
pub struct BroCatli {
    tail: [u8; 2],
    tail_len: u8,
    window_size: u8,
    any_bytes_emitted: bool,
    phase: Phase,
}

Fields§

§tail: [u8; 2]

The last bytes of the output (at most two), held back because they hold the ISLAST and ISLASTEMPTY bits that end the stream, which have to go if another stream is appended.

§tail_len: u8§window_size: u8

The first stream’s window size, or 0 before it is known; later streams may not exceed it.

§any_bytes_emitted: bool

Whether any bytes were written; if none are, finish writes an empty stream.

§phase: Phase

Implementations§

Source§

impl BroCatli

Source

pub fn new() -> Self

Source

pub fn deserialize_from_buffer(buffer: &[u8]) -> Result<BroCatli, ()>

Source

pub fn serialize_to_buffer(&self, buffer: &mut [u8]) -> Result<(), ()>

Source

pub fn new_with_window_size(log_window_size: u8) -> BroCatli

Creates a BroCatli with an initial window size.

Panics for invalid window sizes. Use try_new_with_window_size to detect invalid input without panicking.

Source

pub fn try_new_with_window_size( log_window_size: u8, ) -> Result<BroCatli, BroCatliResult>

Creates a BroCatli with an initial window size, or returns an error for invalid sizes.

Source

pub fn new_brotli_file(&mut self)

Source

pub fn stream( &mut self, in_bytes: &[u8], in_offset: &mut usize, out_bytes: &mut [u8], out_offset: &mut usize, ) -> BroCatliResult

Source

pub fn finish( &mut self, out_bytes: &mut [u8], out_offset: &mut usize, ) -> BroCatliResult

Source

fn read_stream_start( &self, header: &[u8], ) -> Result<(u8, usize, usize), ParseError>

Reads as much of a new stream as splicing it on takes: its window size and, unless it is the first stream, its first meta-block header. Returns the window size and where that header starts and ends, in bits.

Source

fn splice(&mut self, header: &[u8]) -> Result<Option<ByteBuf>, BroCatliResult>

Splices the stream that starts with header onto the output: the output loses its final empty meta-block, the stream loses its window size, and the two are joined bit by bit. The last two bytes of the result become the new tail; the rest is returned, ready to write. Returns Ok(None) if more of the stream is needed to find where it becomes byte aligned.

Source

fn pass_through( &mut self, in_bytes: &[u8], in_offset: &mut usize, out_bytes: &mut [u8], out_offset: &mut usize, ) -> BroCatliResult

Copies the current stream through to the output, keeping its last two bytes in the tail.

Source

fn write_out( &mut self, bytes: &[u8], out_bytes: &mut [u8], out_offset: &mut usize, ) -> usize

Writes as much of bytes as fits, returning how many bytes that was.

Source

fn set_tail(&mut self, bytes: &[u8])

Trait Implementations§

Source§

impl Default for BroCatli

Source§

fn default() -> BroCatli

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.