pub struct ComponentSnapshot {
pub component_fqn: String,
pub version: u32,
pub state: Value,
pub metadata: HashMap<String, Value>,
}Expand description
Component state snapshot.
Stores a component’s serialized state along with metadata for safe restoration.
§Fields
component_fqn: Fully qualified name (namespace::name) for cross-session matchingversion: Format version for compatibility checkingstate: Serialized component statemetadata: Optional additional data (timestamps, checksums, etc.)
Fields§
§component_fqn: StringFully qualified name (namespace::name) for validation.
Uses FQN instead of full ComponentId because UUIDs differ between sessions.
version: u32Snapshot format version.
state: ValueSerialized component state.
metadata: HashMap<String, Value>Optional metadata.
Implementations§
Source§impl ComponentSnapshot
impl ComponentSnapshot
Sourcepub fn from_state<T: Serialize>(
fqn: impl Into<String>,
state: &T,
) -> Result<Self, SnapshotError>
pub fn from_state<T: Serialize>( fqn: impl Into<String>, state: &T, ) -> Result<Self, SnapshotError>
Sourcepub fn empty(fqn: impl Into<String>) -> Self
pub fn empty(fqn: impl Into<String>) -> Self
Creates an empty snapshot (for components with no state).
Sourcepub fn to_state<T: for<'de> Deserialize<'de>>(&self) -> Result<T, SnapshotError>
pub fn to_state<T: for<'de> Deserialize<'de>>(&self) -> Result<T, SnapshotError>
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Adds metadata.
Trait Implementations§
Source§impl Clone for ComponentSnapshot
impl Clone for ComponentSnapshot
Source§fn clone(&self) -> ComponentSnapshot
fn clone(&self) -> ComponentSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ComponentSnapshot
impl Debug for ComponentSnapshot
Source§impl<'de> Deserialize<'de> for ComponentSnapshot
impl<'de> Deserialize<'de> for ComponentSnapshot
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
Auto Trait Implementations§
impl Freeze for ComponentSnapshot
impl RefUnwindSafe for ComponentSnapshot
impl Send for ComponentSnapshot
impl Sync for ComponentSnapshot
impl Unpin for ComponentSnapshot
impl UnsafeUnpin for ComponentSnapshot
impl UnwindSafe for ComponentSnapshot
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