pub struct LabelRegistry { /* private fields */ }Expand description
Bidirectional label ↔ LabelId catalog with concurrent access.
Cloned cheaply via Arc<LabelRegistry> from GraphStore. Internally
uses a single RwLock covering both directions of the map plus the
next-id counter so that allocation + insertion is atomic.
Implementations§
Source§impl LabelRegistry
impl LabelRegistry
Sourcepub fn with_legacy_seed() -> LabelRegistry
pub fn with_legacy_seed() -> LabelRegistry
New empty registry pre-seeded with legacy GraphNodeType and
GraphEdgeType variant names so v1-format records decode into stable
IDs without a separate migration step.
Sourcepub fn empty() -> LabelRegistry
pub fn empty() -> LabelRegistry
New empty registry with no legacy seeding. Use only when callers do not need to decode v1 graph pages.
Sourcepub fn intern(
&self,
ns: Namespace,
label: &str,
) -> Result<LabelId, LabelRegistryError>
pub fn intern( &self, ns: Namespace, label: &str, ) -> Result<LabelId, LabelRegistryError>
Look up an existing label or allocate a new ID. Idempotent.
Sourcepub fn lookup(&self, ns: Namespace, label: &str) -> Option<LabelId>
pub fn lookup(&self, ns: Namespace, label: &str) -> Option<LabelId>
Look up the ID for an existing label. None if not interned.
Sourcepub fn resolve(&self, id: LabelId) -> Option<(Namespace, String)>
pub fn resolve(&self, id: LabelId) -> Option<(Namespace, String)>
Resolve an ID back to its (namespace, label). None for unknown
or sentinel IDs.
Sourcepub fn label_of(&self, ns: Namespace, id: LabelId) -> Option<String>
pub fn label_of(&self, ns: Namespace, id: LabelId) -> Option<String>
Resolve an ID to just its label string, scoped to a namespace.
Returns None if the ID belongs to a different namespace.
Sourcepub fn legacy_node_label_id(disc: u8) -> LabelId
pub fn legacy_node_label_id(disc: u8) -> LabelId
Translate a v1 GraphNodeType discriminant (0..=8) into the
reserved LabelId it was seeded with. Returns UNSET_LABEL_ID for
unknown discriminants (forward-compat).
Sourcepub fn legacy_edge_label_id(disc: u8) -> LabelId
pub fn legacy_edge_label_id(disc: u8) -> LabelId
Translate a v1 GraphEdgeType discriminant (0..=9) into the
reserved LabelId it was seeded with.
Sourcepub fn encode(&self) -> Result<Vec<u8>, LabelRegistryError>
pub fn encode(&self) -> Result<Vec<u8>, LabelRegistryError>
Serialize the catalog to a self-describing byte buffer. Format:
[count: u32 LE]([id: u32 LE][ns: u8][len: u16 LE][label_bytes])*
Sourcepub fn decode(data: &[u8]) -> Result<LabelRegistry, LabelRegistryError>
pub fn decode(data: &[u8]) -> Result<LabelRegistry, LabelRegistryError>
Inverse of [encode]. Returns a fresh registry; the legacy seed is
not re-applied (caller decides whether incoming bytes already
contain the legacy entries).
Trait Implementations§
Source§impl Debug for LabelRegistry
impl Debug for LabelRegistry
Source§impl Default for LabelRegistry
impl Default for LabelRegistry
Source§fn default() -> LabelRegistry
fn default() -> LabelRegistry
Auto Trait Implementations§
impl !Freeze for LabelRegistry
impl RefUnwindSafe for LabelRegistry
impl Send for LabelRegistry
impl Sync for LabelRegistry
impl Unpin for LabelRegistry
impl UnsafeUnpin for LabelRegistry
impl UnwindSafe for LabelRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request