CompDict

Struct CompDict 

Source
pub struct CompDict<L: Allocator + Copy = Global, S: Allocator + Copy = Global> { /* private fields */ }
Expand description

Dictionary for PRS compression.

This dictionary stores the locations of every single possible place that a specified 2-byte sequence can be found, with the 2 byte combination being the dictionary ‘key’. The values (locations) are stored inside a shared buffer, where CompDictEntry dictates the file offsets of the locations which start with this 2 byte combination. The items are stored in ascending order.

When the compressor is looking for longest match at given address, it will read the 2 bytes at the address and use that as key CompDict::get_item. Then the offsets inside the returned entry will be used to greatly speed up search.

Implementations§

Source§

impl<L: Allocator + Copy, S: Allocator + Copy> CompDict<L, S>

Source

pub fn new_in( data_len: usize, long_lived_allocator: L, short_lived_allocator: S, ) -> Self

Create a new CompDict without initializing it.

§Parameters
  • data_len: The length of the data that will be used to initialize the dictionary.
  • long_lived_allocator: The allocator to use for long-lived memory allocation.
  • short_lived_allocator: The allocator to use for short-lived memory allocation.
Source

pub unsafe fn init(&mut self, data: &[u8], offset: usize)

Initialize the CompDict with the given data and offset.

§Parameters
  • data: The data to create the dictionary from.
  • offset: The offset to add to the offsets in the dictionary.
§Safety

This function is unsafe as it operates on raw pointers and assumes that the CompDict has been properly allocated with enough space for data.

Source

pub unsafe fn get_item( &mut self, key: u16, min_ofs: usize, max_ofs: usize, ) -> &[u32]

Returns a slice of offsets for the given key which are greater than or equal to min_ofs and less than or equal to max_ofs.

§Parameters
  • key: The key to search for.
  • min_ofs: The minimum offset returned in the slice.
  • max_ofs: The maximum offset returned in the slice.
§Safety

This function is unsafe as it operates on raw pointers.

Source

pub fn get_dict_mut(&mut self) -> &mut [CompDictEntry; 65536]

Retrieves the dictionary entries section of this CompDict.

Source§

impl CompDict

Source

pub fn new(data_len: usize) -> Self

Create a new CompDict without initializing it.

§Parameters
  • data_len: The length of the data that will be used to initialize the dictionary.

Trait Implementations§

Source§

impl<L: Allocator + Copy, S: Allocator + Copy> Drop for CompDict<L, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<L, S> Freeze for CompDict<L, S>
where L: Freeze, S: Freeze,

§

impl<L, S> RefUnwindSafe for CompDict<L, S>

§

impl<L = Global, S = Global> !Send for CompDict<L, S>

§

impl<L = Global, S = Global> !Sync for CompDict<L, S>

§

impl<L, S> Unpin for CompDict<L, S>
where L: Unpin, S: Unpin,

§

impl<L, S> UnwindSafe for CompDict<L, S>
where L: UnwindSafe, S: UnwindSafe,

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.