Skip to main content

Flat

Struct Flat 

Source
pub struct Flat { /* private fields */ }
Expand description

A decoded chunk as one buffer with the values laid end to end, and where each one ends in it.

This is what the decoder builds and decode is a copy out of it. The cascade is why: a nest like FRONT(LZ(FSST)) decodes three levels to produce one, and a level that hands its caller a Vec<Vec<u8>> has allocated once per value and copied every byte it holds. Three levels of that on a chunk of a thousand URLs is three thousand allocations to produce a thousand strings that the caller almost always wants back to back anyway.

It also makes the levels cheaper on their own terms. PLAIN is one memcpy of the whole payload because the values are already end to end in the file. FRONT copies a shared prefix out of the buffer it is writing into, so the previous value never has to be somewhere else. LZ replays straight into the buffer, which is what its copy offsets meant in the first place.

Implementations§

Source§

impl Flat

Source

pub fn len(&self) -> usize

How many values the chunk holds.

Source

pub fn is_empty(&self) -> bool

Whether the chunk holds no values at all, which is not the same as holding empty ones.

Source

pub fn bytes(&self) -> &[u8]

The values laid end to end. A caller that already knows the boundaries, which is what a global dictionary’s offsets are, needs nothing else.

Source

pub fn get(&self, index: usize) -> Option<&[u8]>

The value at index, or None past the end.

Source

pub fn iter(&self) -> impl Iterator<Item = &[u8]>

Every value in order.

Source

pub fn into_bytes(self) -> Vec<u8>

The buffer on its own, for a caller that wanted the bytes rather than the values.

Trait Implementations§

Source§

impl Clone for Flat

Source§

fn clone(&self) -> Flat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Flat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Flat

Source§

fn default() -> Flat

Returns the “default value” for a type. Read more
Source§

impl Eq for Flat

Source§

impl PartialEq for Flat

Source§

fn eq(&self, other: &Flat) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Flat

Auto Trait Implementations§

§

impl Freeze for Flat

§

impl RefUnwindSafe for Flat

§

impl Send for Flat

§

impl Sync for Flat

§

impl Unpin for Flat

§

impl UnsafeUnpin for Flat

§

impl UnwindSafe for Flat

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.