Struct ruzstd::blocks::literals_section::LiteralsSection
source · pub struct LiteralsSection {
pub regenerated_size: u32,
pub compressed_size: Option<u32>,
pub num_streams: Option<u8>,
pub ls_type: LiteralsSectionType,
}
Expand description
A compressed block consists of two sections, a literals section, and a sequences section.
This is the first of those two sections. A literal is just any arbitrary data, and it is copied by the sequences section
Fields§
§regenerated_size: u32
- If this block is of type LiteralsSectionType::Raw, then the data is
regenerated_bytes
bytes long, and it contains the raw literals data to be used during the second section, the sequences section. - If this block is of type LiteralsSectionType::RLE,
then the literal consists of a single byte repeated
regenerated_size
times. - For types LiteralsSectionType::Compressed or LiteralsSectionType::Treeless, then this is the size of the decompressed data.
compressed_size: Option<u32>
- For types LiteralsSectionType::Raw and LiteralsSectionType::RLE, this value is not present.
- For types LiteralsSectionType::Compressed and LiteralsSectionType::Treeless, this value will be set to the size of the compressed data.
num_streams: Option<u8>
This value will be either 1 stream or 4 streams if the literal is of type LiteralsSectionType::Compressed or LiteralsSectionType::Treeless, and it is not used for RLE or uncompressed literals.
ls_type: LiteralsSectionType
The type of the literal section.
Implementations§
source§impl LiteralsSection
impl LiteralsSection
sourcepub fn new() -> LiteralsSection
pub fn new() -> LiteralsSection
Create a new LiteralsSection.
sourcepub fn header_bytes_needed(
&self,
first_byte: u8,
) -> Result<u8, LiteralsSectionParseError>
pub fn header_bytes_needed( &self, first_byte: u8, ) -> Result<u8, LiteralsSectionParseError>
Given the first byte of a header, determine the size of the whole header, from 1 to 5 bytes.
sourcepub fn parse_from_header(
&mut self,
raw: &[u8],
) -> Result<u8, LiteralsSectionParseError>
pub fn parse_from_header( &mut self, raw: &[u8], ) -> Result<u8, LiteralsSectionParseError>
Parse the header into self
, and returns the number of bytes read.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LiteralsSection
impl RefUnwindSafe for LiteralsSection
impl Send for LiteralsSection
impl Sync for LiteralsSection
impl Unpin for LiteralsSection
impl UnwindSafe for LiteralsSection
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