pub struct Reference {
pub type_name: Option<Box<str>>,
pub id: Box<str>,
}Expand description
A reference to another node.
Optimized memory layout:
- 16 bytes on 64-bit systems (without heap allocation for short IDs)
- Type names are interned during parsing to reduce duplication
- Uses
Box<str>to minimize heap overhead compared to String
Fields§
§type_name: Option<Box<str>>Optional type qualifier (e.g., “User” in “@User:id”). Boxed to reduce size when None (common case).
id: Box<str>The ID being referenced.
Uses Box<str> for compact representation (16 bytes vs 24 for String).
Implementations§
Source§impl Reference
impl Reference
Sourcepub fn qualified(type_name: impl Into<String>, id: impl Into<String>) -> Self
pub fn qualified(type_name: impl Into<String>, id: impl Into<String>) -> Self
Create a qualified reference with type name.
Sourcepub fn unqualified(id: impl Into<String>) -> Self
pub fn unqualified(id: impl Into<String>) -> Self
Create an unqualified reference (alias for local).
An unqualified reference has no type qualifier and will be resolved based on context (current type in matrix lists, or global search with ambiguity detection in key-value context).
Sourcepub fn to_ref_string(&self) -> String
pub fn to_ref_string(&self) -> String
Format as a reference string (with @).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Reference
impl<'de> Deserialize<'de> for Reference
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Reference
Auto Trait Implementations§
impl Freeze for Reference
impl RefUnwindSafe for Reference
impl Send for Reference
impl Sync for Reference
impl Unpin for Reference
impl UnwindSafe for Reference
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more