pub struct TypesContextSnapshot {
pub facts: HashMap<TypesContextKey, Vec<FactId>>,
pub intent_id: Option<IntentId>,
pub metadata: HashMap<String, String>,
pub version: u64,
}Expand description
Immutable context snapshot.
This represents a point-in-time view of context. The existing context::Context remains for runtime mutation; this is for snapshot/serialization.
Uses “Types” prefix to avoid collision with existing Context.
Fields§
§facts: HashMap<TypesContextKey, Vec<FactId>>Facts organized by key.
intent_id: Option<IntentId>Root intent ID.
metadata: HashMap<String, String>Metadata.
version: u64Version number for optimistic concurrency.
Implementations§
Source§impl TypesContextSnapshot
impl TypesContextSnapshot
Sourcepub fn empty() -> TypesContextSnapshot
pub fn empty() -> TypesContextSnapshot
Create an empty context snapshot.
Sourcepub fn get(&self, key: &TypesContextKey) -> &[FactId]
pub fn get(&self, key: &TypesContextKey) -> &[FactId]
Get fact IDs for a key.
Sourcepub fn has(&self, key: &TypesContextKey) -> bool
pub fn has(&self, key: &TypesContextKey) -> bool
Check if key has facts.
Sourcepub fn total_facts(&self) -> usize
pub fn total_facts(&self) -> usize
Get total number of facts across all keys.
Sourcepub fn keys(&self) -> impl Iterator<Item = &TypesContextKey>
pub fn keys(&self) -> impl Iterator<Item = &TypesContextKey>
Get all keys that have facts.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&str>
pub fn get_metadata(&self, key: &str) -> Option<&str>
Get metadata value.
Sourcepub fn increment_version(&self) -> TypesContextSnapshot
pub fn increment_version(&self) -> TypesContextSnapshot
Create a new version with incremented version number.
Sourcepub fn to_builder(&self) -> ContextBuilder
pub fn to_builder(&self) -> ContextBuilder
Convert to builder for modifications.
Trait Implementations§
Source§impl Clone for TypesContextSnapshot
impl Clone for TypesContextSnapshot
Source§fn clone(&self) -> TypesContextSnapshot
fn clone(&self) -> TypesContextSnapshot
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 TypesContextSnapshot
impl Debug for TypesContextSnapshot
Source§impl Default for TypesContextSnapshot
impl Default for TypesContextSnapshot
Source§fn default() -> TypesContextSnapshot
fn default() -> TypesContextSnapshot
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for TypesContextSnapshot
impl<'de> Deserialize<'de> for TypesContextSnapshot
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TypesContextSnapshot, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TypesContextSnapshot, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for TypesContextSnapshot
impl Serialize for TypesContextSnapshot
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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for TypesContextSnapshot
impl RefUnwindSafe for TypesContextSnapshot
impl Send for TypesContextSnapshot
impl Sync for TypesContextSnapshot
impl Unpin for TypesContextSnapshot
impl UnsafeUnpin for TypesContextSnapshot
impl UnwindSafe for TypesContextSnapshot
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