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: u8The first stream’s window size, or 0 before it is known; later streams may not exceed it.
any_bytes_emitted: boolWhether any bytes were written; if none are, finish writes an empty stream.
phase: PhaseImplementations§
Source§impl BroCatli
impl BroCatli
pub fn new() -> Self
pub fn deserialize_from_buffer(buffer: &[u8]) -> Result<BroCatli, ()>
pub fn serialize_to_buffer(&self, buffer: &mut [u8]) -> Result<(), ()>
Sourcepub fn new_with_window_size(log_window_size: u8) -> BroCatli
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.
Sourcepub fn try_new_with_window_size(
log_window_size: u8,
) -> Result<BroCatli, BroCatliResult>
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.
pub fn new_brotli_file(&mut self)
pub fn stream( &mut self, in_bytes: &[u8], in_offset: &mut usize, out_bytes: &mut [u8], out_offset: &mut usize, ) -> BroCatliResult
pub fn finish( &mut self, out_bytes: &mut [u8], out_offset: &mut usize, ) -> BroCatliResult
Sourcefn read_stream_start(
&self,
header: &[u8],
) -> Result<(u8, usize, usize), ParseError>
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.
Sourcefn splice(&mut self, header: &[u8]) -> Result<Option<ByteBuf>, BroCatliResult>
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.
Sourcefn pass_through(
&mut self,
in_bytes: &[u8],
in_offset: &mut usize,
out_bytes: &mut [u8],
out_offset: &mut usize,
) -> BroCatliResult
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.
Sourcefn write_out(
&mut self,
bytes: &[u8],
out_bytes: &mut [u8],
out_offset: &mut usize,
) -> usize
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.