pub struct IdMap { /* private fields */ }Implementations§
Source§impl IdMap
impl IdMap
pub fn new() -> Self
Sourcepub fn get_or_insert(&mut self, key: &str) -> u32
pub fn get_or_insert(&mut self, key: &str) -> u32
Convenience wrapper around Self::try_insert for call-sites that do not
return Result. Panics only when the u32 id space is exhausted (> 4 billion
distinct node keys inserted without restart). Converting this to return
Result<u32> requires a public API change — tracked as a TODO-0.4.2 task.
Sourcepub fn try_insert(&mut self, key: &str) -> Result<u32>
pub fn try_insert(&mut self, key: &str) -> Result<u32>
Allocate a dense id for key, or return the existing live id.
Fails before wrap when the next id would not fit in u32.
pub fn get(&self, key: &str) -> Option<u32>
pub fn key_of(&self, id: u32) -> Option<&str>
Sourcepub fn key_of_historical(&self, id: u32) -> Option<&str>
pub fn key_of_historical(&self, id: u32) -> Option<&str>
Like key_of, but also resolves tombstoned ids.
Use only for historical WAL scan paths (e.g. edge_history) where the
goal is to reconstruct what existed in the past, not the current live
state. All other callers should use key_of.
Sourcepub fn rename(&mut self, old: &str, new: &str) -> Result<u32>
pub fn rename(&mut self, old: &str, new: &str) -> Result<u32>
Rename a live key, keeping its dense id stable.
Returns Err(KeyNotFound) if old is unknown or tombstoned.
Returns Err(DuplicateKey) if new is already a live key.
On success returns the stable id shared by both names.
Sourcepub fn delete(&mut self, key: &str) -> Option<u32>
pub fn delete(&mut self, key: &str) -> Option<u32>
Remove key from the live map, permanently tombstone its dense id, and
return that id. Returns None if the key is not present.
Sourcepub fn is_tombstoned(&self, id: u32) -> bool
pub fn is_tombstoned(&self, id: u32) -> bool
Returns true if id has been retired by a prior delete call.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of total id slots ever allocated (live + tombstoned). Stable across
deletes and re-inserts — use live_len for the live count.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IdMap
impl<'de> Deserialize<'de> for IdMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for IdMap
impl RefUnwindSafe for IdMap
impl Send for IdMap
impl Sync for IdMap
impl Unpin for IdMap
impl UnsafeUnpin for IdMap
impl UnwindSafe for IdMap
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.