pub struct Cache<DK, DV> { /* private fields */ }
Expand description
Implementations§
Source§impl<DK, DV> Cache<DK, DV>
impl<DK, DV> Cache<DK, DV>
pub fn new(index_bytes: DK, value_bytes: DV) -> Result<Self, Error>
Sourcepub fn index(&self) -> &Map<DK>
pub fn index(&self) -> &Map<DK>
Access the internal fst::Map
used for mapping keys to value offsets.
Sourcepub fn value_bytes(&self) -> &[u8] ⓘ
pub fn value_bytes(&self) -> &[u8] ⓘ
The entire byte slice storing all values.
Sourcepub fn get_value_offset(&self, key: &[u8]) -> Option<u64>
pub fn get_value_offset(&self, key: &[u8]) -> Option<u64>
Returns the byte offset of the value for key
, if it exists.
The returned offset can be used with the value_at_offset
method.
Sourcepub unsafe fn offset_transmuted_value<T>(&self, offset: usize) -> &T
pub unsafe fn offset_transmuted_value<T>(&self, offset: usize) -> &T
Transmutes the bytes starting at offset
into a T
reference.
§Safety
offset
must point to a valid representation of T
in the value_bytes
region of memory.
Sourcepub unsafe fn get_transmuted_value<T>(&self, key: &[u8]) -> Option<&T>
pub unsafe fn get_transmuted_value<T>(&self, key: &[u8]) -> Option<&T>
Transmutes the bytes pointed to by key
(if any) into a T
reference.
§Safety
key
must point to a valid representation of T
in the value_bytes
region of memory.
Sourcepub fn range<K, R>(&self, key_range: R) -> StreamBuilder<'_>
pub fn range<K, R>(&self, key_range: R) -> StreamBuilder<'_>
Returns a streaming iterator over (key, value offset) pairs.
The offset is a byte offset pointing to the start of the value for that key.
Sourcepub fn first<const N: usize>(&self) -> Option<([u8; N], u64)>
pub fn first<const N: usize>(&self) -> Option<([u8; N], u64)>
Returns the (lexicographical) first (key, value) pair.
§Panics
If the actual first key is longer than N
.