pub struct ContextFact { /* private fields */ }Expand description
Read-only projection of a validated assertion in the context.
This type is not promotion authority. It is the value suggestors and
pack authors can read from context after the engine has promoted a
proposal. Constructing one locally does not admit it into Converge; there is
no public API that accepts a ContextFact as promoted truth.
Implementations§
Source§impl ContextFact
impl ContextFact
Sourcepub fn new_projection<T>(
key: ContextKey,
id: impl Into<FactId>,
payload: T,
promotion_record: FactPromotionRecord,
created_at: impl Into<Timestamp>,
) -> ContextFactwhere
T: FactPayload + PartialEq,
pub fn new_projection<T>(
key: ContextKey,
id: impl Into<FactId>,
payload: T,
promotion_record: FactPromotionRecord,
created_at: impl Into<Timestamp>,
) -> ContextFactwhere
T: FactPayload + PartialEq,
Creates a read-only context projection.
This constructor does not promote anything and is intentionally named as
a projection constructor. The engine is still the only component that can
add context facts to a live ContextState.
Sourcepub fn from_wire(
wire: WireContextFact,
registry: &PayloadRegistry,
) -> Result<ContextFact, PayloadError>
pub fn from_wire( wire: WireContextFact, registry: &PayloadRegistry, ) -> Result<ContextFact, PayloadError>
Creates a context fact from a wire representation at a serialization border.
Sourcepub fn to_wire(&self) -> Result<WireContextFact, PayloadError>
pub fn to_wire(&self) -> Result<WireContextFact, PayloadError>
Converts this fact to the stable wire shape.
Sourcepub fn key(&self) -> ContextKey
pub fn key(&self) -> ContextKey
Returns the context key this fact belongs to.
Sourcepub fn payload<T>(&self) -> Option<&T>where
T: FactPayload,
pub fn payload<T>(&self) -> Option<&T>where
T: FactPayload,
Returns the typed payload when the requested type matches the stored payload family/version.
Sourcepub fn require_payload<T>(&self) -> Result<&T, PayloadError>where
T: FactPayload,
pub fn require_payload<T>(&self) -> Result<&T, PayloadError>where
T: FactPayload,
Returns the typed payload or a mismatch error.
Sourcepub fn payload_family(&self) -> FactFamilyId
pub fn payload_family(&self) -> FactFamilyId
Returns the payload family.
Sourcepub fn payload_version(&self) -> PayloadVersion
pub fn payload_version(&self) -> PayloadVersion
Returns the payload version.
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Returns the payload as text when this is a TextPayload.
Sourcepub fn validate_payload(&self) -> Result<(), PayloadError>
pub fn validate_payload(&self) -> Result<(), PayloadError>
Validates the stored payload.
Sourcepub fn promotion_record(&self) -> &FactPromotionRecord
pub fn promotion_record(&self) -> &FactPromotionRecord
Returns the immutable promotion record for this fact.
Sourcepub fn created_at(&self) -> &Timestamp
pub fn created_at(&self) -> &Timestamp
Returns the fact creation timestamp.
Sourcepub fn is_replay_eligible(&self) -> bool
pub fn is_replay_eligible(&self) -> bool
Returns whether the fact is replay-eligible.
Trait Implementations§
Source§impl Clone for ContextFact
impl Clone for ContextFact
Source§fn clone(&self) -> ContextFact
fn clone(&self) -> ContextFact
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContextFact
impl Debug for ContextFact
Source§impl PartialEq for ContextFact
impl PartialEq for ContextFact
Source§fn eq(&self, other: &ContextFact) -> bool
fn eq(&self, other: &ContextFact) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ContextFact
impl Serialize for ContextFact
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 Eq for ContextFact
Auto Trait Implementations§
impl Freeze for ContextFact
impl !RefUnwindSafe for ContextFact
impl Send for ContextFact
impl Sync for ContextFact
impl Unpin for ContextFact
impl UnsafeUnpin for ContextFact
impl !UnwindSafe for ContextFact
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
key and return true if they are equal.