pub struct NodeId(/* private fields */);Expand description
A content-addressed 128-bit node identity.
NodeId is the primary key used throughout the Fission pipeline to refer to a
specific node. Because it is derived from BLAKE3 hashes, two nodes with the same
derivation inputs always produce the same NodeId, which makes tree diffing cheap.
§Construction
use fission_ir::NodeId;
// From a stable string key (good for well-known, named nodes):
let id = NodeId::explicit("sidebar");
// From a parent ID and a position path (good for list items):
let parent = NodeId::explicit("list");
let item_3 = NodeId::derived(parent.as_u128(), &[3]);§Equality and hashing
NodeId implements Eq, Hash, and Ord, so it can be used as a key in
HashMap, BTreeMap, and HashSet.
Implementations§
Source§impl NodeId
impl NodeId
Sourcepub const fn from_u128(val: u128) -> NodeId
pub const fn from_u128(val: u128) -> NodeId
Creates a NodeId from a raw 128-bit value.
This is intended for internal use or deserialization. In most cases you
should use NodeId::explicit or NodeId::derived instead.
Sourcepub fn as_u128(&self) -> u128
pub fn as_u128(&self) -> u128
Returns the underlying 128-bit value.
Useful when you need to feed a node’s identity into another hash (e.g.,
when deriving child IDs with NodeId::derived).
Sourcepub fn explicit(key: &str) -> NodeId
pub fn explicit(key: &str) -> NodeId
Creates a NodeId from a user-provided string key.
The key is hashed with BLAKE3 (prefixed with "explicit:"), producing a
deterministic ID that is stable across rebuilds as long as the key string
does not change. Use this for well-known, named nodes like "root" or
"toolbar".
§Example
use fission_ir::NodeId;
let a = NodeId::explicit("header");
let b = NodeId::explicit("header");
assert_eq!(a, b); // same key -> same IDSourcepub fn derived(parent: u128, path: &[u32]) -> NodeId
pub fn derived(parent: u128, path: &[u32]) -> NodeId
Creates a NodeId derived from a parent ID and a child-index path.
This implements structural identity: a node’s ID is determined by its position in the tree rather than by a user-provided name. Useful for dynamically generated children like list items.
§Arguments
parent– The parent node’s rawu128value (seeNodeId::as_u128).path– One or more child indices describing the path from the parent.
§Example
use fission_ir::NodeId;
let parent = NodeId::explicit("list");
let item_0 = NodeId::derived(parent.as_u128(), &[0]);
let item_1 = NodeId::derived(parent.as_u128(), &[1]);
assert_ne!(item_0, item_1);Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodeId
impl<'de> Deserialize<'de> for NodeId
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodeId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodeId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<NodeId> for WidgetNodeId
impl From<NodeId> for WidgetNodeId
Source§fn from(node: NodeId) -> WidgetNodeId
fn from(node: NodeId) -> WidgetNodeId
Source§impl From<WidgetNodeId> for NodeId
impl From<WidgetNodeId> for NodeId
Source§fn from(id: WidgetNodeId) -> NodeId
fn from(id: WidgetNodeId) -> NodeId
Source§impl Ord for NodeId
impl Ord for NodeId
Source§impl PartialOrd for NodeId
impl PartialOrd for NodeId
Source§impl Serialize for NodeId
impl Serialize for NodeId
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for NodeId
impl Eq for NodeId
impl StructuralPartialEq for NodeId
Auto Trait Implementations§
impl Freeze for NodeId
impl RefUnwindSafe for NodeId
impl Send for NodeId
impl Sync for NodeId
impl Unpin for NodeId
impl UnsafeUnpin for NodeId
impl UnwindSafe for NodeId
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.