pub struct StateKey {
pub widget_type: &'static str,
pub instance_id: String,
}Expand description
Unique identifier for a widget’s persisted state.
A StateKey is the (widget_type, instance_id) pair that maps a widget
instance to its stored state blob. Widget type is a &'static str (cheap
to copy, no allocation) while instance id is an owned String to support
dynamic widget trees.
§Construction
// Explicit
let key = StateKey::new("ScrollView", "main-content");
// From a widget-tree path
let key = StateKey::from_path(&["app", "sidebar", "tree"]);
assert_eq!(key.instance_id, "app/sidebar/tree");Fields§
§widget_type: &'static strThe widget type name (e.g., "ScrollView", "TreeView").
instance_id: StringInstance-unique identifier within a widget tree.
Implementations§
Source§impl StateKey
impl StateKey
Sourcepub fn new(widget_type: &'static str, id: impl Into<String>) -> Self
pub fn new(widget_type: &'static str, id: impl Into<String>) -> Self
Create a new state key from a widget type and instance id.
Trait Implementations§
impl Eq for StateKey
impl StructuralPartialEq for StateKey
Auto Trait Implementations§
impl Freeze for StateKey
impl RefUnwindSafe for StateKey
impl Send for StateKey
impl Sync for StateKey
impl Unpin for StateKey
impl UnwindSafe for StateKey
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.