pub struct OffsetIndex {
pub name: String,
pub offsets: IndexMap<Box<str>, u64>,
pub init: bool,
}
Expand description
An ordered mapping from entity ID to byte offset into the source file it resides in.
A wrapper around indexmap::IndexMap
.
Fields§
§name: String
The name of the index. There may potentially be more than one index per file
offsets: IndexMap<Box<str>, u64>
The mapping from ID to byte offset, ordered by occurrence
init: bool
Whether the index has been initalized explicitly or not, as it may be initially empty or read as empty.
Implementations§
Source§impl OffsetIndex
impl OffsetIndex
pub fn new(name: String) -> OffsetIndex
Sourcepub fn get_index(&self, index: usize) -> Option<(&str, u64)>
pub fn get_index(&self, index: usize) -> Option<(&str, u64)>
Get the associated key and offset for the specified index position
Sourcepub fn index_of(&self, key: &str) -> Option<usize>
pub fn index_of(&self, key: &str) -> Option<usize>
Get the position in the index for a specific key
Sourcepub fn insert<T>(&mut self, key: T, offset: u64) -> Option<u64>
pub fn insert<T>(&mut self, key: T, offset: u64) -> Option<u64>
Insert key
into the index with an offset value
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn keys(&self) -> Keys<'_, Box<str>, u64>
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if the key is in the index
Trait Implementations§
Source§impl Clone for OffsetIndex
impl Clone for OffsetIndex
Source§fn clone(&self) -> OffsetIndex
fn clone(&self) -> OffsetIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for OffsetIndex
impl Debug for OffsetIndex
Source§impl Default for OffsetIndex
impl Default for OffsetIndex
Source§fn default() -> OffsetIndex
fn default() -> OffsetIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OffsetIndex
impl RefUnwindSafe for OffsetIndex
impl Send for OffsetIndex
impl Sync for OffsetIndex
impl Unpin for OffsetIndex
impl UnwindSafe for OffsetIndex
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