pub struct WidgetId(/* private fields */);Expand description
A stable 128-bit identity for widgets and lowered IR nodes.
WidgetId values are derived from BLAKE3 hashes. Two construction strategies
are available:
WidgetId::explicithashes a user-provided stable key.WidgetId::derivedhashes a parent identity plus a child-index path.
§Example
use fission_ir::WidgetId;
let sidebar = WidgetId::explicit("sidebar");
let first_item = WidgetId::derived(sidebar.as_u128(), &[0]);
assert_ne!(sidebar, first_item);Implementations§
Source§impl WidgetId
impl WidgetId
Sourcepub const fn from_u128(val: u128) -> WidgetId
pub const fn from_u128(val: u128) -> WidgetId
Creates a WidgetId from a raw 128-bit value.
This is intended for internal use or deserialization. In normal code use
WidgetId::explicit or WidgetId::derived instead.
Sourcepub fn explicit(key: &str) -> WidgetId
pub fn explicit(key: &str) -> WidgetId
Creates a WidgetId from a user-provided stable key.
The key is hashed with BLAKE3 using the same explicit-identity domain as the original IR identity system. Keep the key stable across rebuilds when you want runtime state, focus, scroll, animation, or host-surface state to follow a widget through tree changes.
Sourcepub fn derived(parent: u128, path: &[u32]) -> WidgetId
pub fn derived(parent: u128, path: &[u32]) -> WidgetId
Creates a WidgetId derived from a parent identity and child-index path.
This provides structural identity for children that do not have explicit keys. Dynamic/reorderable lists should provide explicit IDs for list items; purely structural children can use derived IDs.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for WidgetId
impl<'de> Deserialize<'de> for WidgetId
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<WidgetId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<WidgetId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for WidgetId
impl Ord for WidgetId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for WidgetId
impl PartialOrd for WidgetId
Source§impl Serialize for WidgetId
impl Serialize for WidgetId
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 WidgetId
impl Eq for WidgetId
impl StructuralPartialEq for WidgetId
Auto Trait Implementations§
impl Freeze for WidgetId
impl RefUnwindSafe for WidgetId
impl Send for WidgetId
impl Sync for WidgetId
impl Unpin for WidgetId
impl UnsafeUnpin for WidgetId
impl UnwindSafe for WidgetId
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.