pub struct Interaction {Show 17 fields
pub id: InteractionId,
pub account_id: AccountId,
pub conversation_id: ConversationId,
pub case_ref: CaseRef,
pub created_by_turn: TurnId,
pub kind: InteractionKind,
pub blocking: bool,
pub payload: InteractionPayload,
pub payload_hash: Digest,
pub status: InteractionStatus,
pub revision_independent: bool,
pub text_resolution: TextResolutionPolicy,
pub confirms_risk: RiskClass,
pub created_at: DateTime<Utc>,
pub expires_at: Option<DateTime<Utc>>,
pub resolved_at: Option<DateTime<Utc>>,
pub resolved_option_id: Option<OptionId>,
}Expand description
A persisted interaction (spec §15.1).
Fields§
§id: InteractionIdIdentifier.
account_id: AccountIdOwning tenant.
conversation_id: ConversationIdOwning conversation.
case_ref: CaseRefCase and the revision the card was rendered against (the bound revision).
created_by_turn: TurnIdTurn that created it.
kind: InteractionKindShape.
blocking: boolWhether it owns unqualified answers for the case.
payload: InteractionPayloadImmutable content.
payload_hash: DigestHash of payload at creation.
status: InteractionStatusLifecycle status.
revision_independent: booltrue when a revision change does not invalidate it.
text_resolution: TextResolutionPolicyWhether typed text may resolve it.
confirms_risk: RiskClassHighest risk class of the commands an answer authorizes. Conservative
(RiskClass::Irreversible) when a stored record predates the field.
created_at: DateTime<Utc>Creation time.
expires_at: Option<DateTime<Utc>>Expiry, if any.
resolved_at: Option<DateTime<Utc>>Resolution time, if resolved.
resolved_option_id: Option<OptionId>Option chosen, if resolved.
Implementations§
Source§impl Interaction
impl Interaction
Sourcepub fn from_spec(
spec: InteractionSpec,
id: InteractionId,
account_id: AccountId,
conversation_id: ConversationId,
created_by_turn: TurnId,
now: DateTime<Utc>,
) -> Result<Self, InteractionError>
pub fn from_spec( spec: InteractionSpec, id: InteractionId, account_id: AccountId, conversation_id: ConversationId, created_by_turn: TurnId, now: DateTime<Utc>, ) -> Result<Self, InteractionError>
Materializes a spec into a new Active interaction, computing the
payload hash and the expiry.
Fails closed: a card that cannot be answered
(InteractionSpec::validate) or whose time to live cannot be applied
is never persisted. Silently dropping an out-of-range TTL would produce
a card that never expires, which is a fail-open on a safety timeout.
Sourcepub fn bound_revision(&self) -> Option<CaseRevision>
pub fn bound_revision(&self) -> Option<CaseRevision>
The revision the card is bound to, or None when revision independent.
Sourcepub fn is_expired(&self, now: DateTime<Utc>) -> bool
pub fn is_expired(&self, now: DateTime<Utc>) -> bool
Returns true when now is past the expiry.
Sourcepub fn verify_payload_hash(&self) -> Result<bool, HashError>
pub fn verify_payload_hash(&self) -> Result<bool, HashError>
Recomputes the payload hash and compares it with the stored one.
Sourcepub fn transition(
&mut self,
to: InteractionStatus,
) -> Result<(), InteractionError>
pub fn transition( &mut self, to: InteractionStatus, ) -> Result<(), InteractionError>
Applies a status transition, refusing illegal ones.
Sourcepub fn begin_resolution(
&mut self,
option_id: OptionId,
now: DateTime<Utc>,
) -> Result<(), InteractionError>
pub fn begin_resolution( &mut self, option_id: OptionId, now: DateTime<Utc>, ) -> Result<(), InteractionError>
Records the chosen option and moves to Resolving.
Sourcepub fn view(&self) -> InteractionView
pub fn view(&self) -> InteractionView
The client-facing projection without server actions.
Trait Implementations§
Source§impl Clone for Interaction
impl Clone for Interaction
Source§impl Debug for Interaction
impl Debug for Interaction
Source§impl<'de> Deserialize<'de> for Interaction
impl<'de> Deserialize<'de> for Interaction
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>,
impl Eq for Interaction
Source§impl PartialEq for Interaction
impl PartialEq for Interaction
Source§impl Serialize for Interaction
impl Serialize for Interaction
impl StructuralPartialEq for Interaction
Auto Trait Implementations§
impl Freeze for Interaction
impl RefUnwindSafe for Interaction
impl Send for Interaction
impl Sync for Interaction
impl Unpin for Interaction
impl UnsafeUnpin for Interaction
impl UnwindSafe for Interaction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.