Struct zerotrie::byte_phf::PerfectByteHashMap

source ·
#[repr(transparent)]
pub struct PerfectByteHashMap<Store: ?Sized>(Store);
Expand description

A constant-time map from bytes to unique indices.

Uses a perfect hash function (see module-level documentation). Does not support mutation.

Standard layout: P, N bytes of Q, N bytes of expected keys

Tuple Fields§

§0: Store

Implementations§

source§

impl PerfectByteHashMap<Vec<u8>>

source

pub fn try_new(keys: &[u8]) -> Result<Self, Error>

Computes a new PerfectByteHashMap.

(this is a doc-hidden API)

source§

impl<Store> PerfectByteHashMap<Store>

source

pub fn from_store(store: Store) -> Self

Creates an instance from a pre-existing store. See Self::as_bytes.

source§

impl<Store> PerfectByteHashMap<Store>
where Store: AsRef<[u8]> + ?Sized,

source

pub fn get(&self, key: u8) -> Option<usize>

Gets the usize for the given byte, or None if it is not in the map.

source

pub fn num_items(&self) -> usize

This is called num_items because len is ambiguous: it could refer to the number of items or the number of bytes.

source

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

Get an iterator over the keys in the order in which they are stored in the map.

source

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

Returns the map as bytes. The map can be recovered with Self::from_store or Self::from_bytes.

source§

impl PerfectByteHashMap<[u8]>

source

pub fn from_bytes(bytes: &[u8]) -> &Self

Creates an instance from pre-existing bytes. See Self::as_bytes.

source§

impl<Store> PerfectByteHashMap<Store>
where Store: AsRef<[u8]> + ?Sized,

source

pub fn as_borrowed(&self) -> &PerfectByteHashMap<[u8]>

Converts from PerfectByteHashMap<AsRef<[u8]>> to &PerfectByteHashMap<[u8]>

Trait Implementations§

source§

impl<Store: Debug + ?Sized> Debug for PerfectByteHashMap<Store>

source§

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

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

impl<Store: PartialEq + ?Sized> PartialEq for PerfectByteHashMap<Store>

source§

fn eq(&self, other: &PerfectByteHashMap<Store>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Store: Eq + ?Sized> Eq for PerfectByteHashMap<Store>

source§

impl<Store: ?Sized> StructuralPartialEq for PerfectByteHashMap<Store>

Auto Trait Implementations§

§

impl<Store> Freeze for PerfectByteHashMap<Store>
where Store: Freeze + ?Sized,

§

impl<Store> RefUnwindSafe for PerfectByteHashMap<Store>
where Store: RefUnwindSafe + ?Sized,

§

impl<Store> Send for PerfectByteHashMap<Store>
where Store: Send + ?Sized,

§

impl<Store> Sync for PerfectByteHashMap<Store>
where Store: Sync + ?Sized,

§

impl<Store> Unpin for PerfectByteHashMap<Store>
where Store: Unpin + ?Sized,

§

impl<Store> UnwindSafe for PerfectByteHashMap<Store>
where Store: UnwindSafe + ?Sized,

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>,

§

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>,

§

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.
source§

impl<T> ErasedDestructor for T
where T: 'static,