pub struct FactIndex { /* private fields */ }Expand description
In-memory index of durable FactKey -> ArtifactId bindings.
The engine rebuilds this index from prior domain events before executing a run.
Implementations§
Source§impl FactIndex
impl FactIndex
Sourcepub fn from_event_stream(stream: &[EventEnvelope]) -> Self
pub fn from_event_stream(stream: &[EventEnvelope]) -> Self
Rebuilds the durable fact bindings recorded in an event stream.
Only the first durable binding for a given key is kept, matching the single-assignment contract used by live/replay IO.
Sourcepub async fn get(&self, key: &FactKey) -> Option<ArtifactId>
pub async fn get(&self, key: &FactKey) -> Option<ArtifactId>
Returns the currently bound payload id for key, if one exists.
Sourcepub async fn bind_if_unset(
&self,
key: FactKey,
payload_id: ArtifactId,
) -> (ArtifactId, bool)
pub async fn bind_if_unset( &self, key: FactKey, payload_id: ArtifactId, ) -> (ArtifactId, bool)
Binds key to payload_id only if the key is not already bound.
Returns the effective payload id together with a flag indicating whether a new binding was inserted.
Sourcepub async fn unbind_if_matches(
&self,
key: &FactKey,
payload_id: &ArtifactId,
) -> bool
pub async fn unbind_if_matches( &self, key: &FactKey, payload_id: &ArtifactId, ) -> bool
Removes the binding for key only when it still points to payload_id.
This is used to roll back optimistic in-memory bindings when durable recording fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FactIndex
impl !RefUnwindSafe for FactIndex
impl Send for FactIndex
impl Sync for FactIndex
impl Unpin for FactIndex
impl UnsafeUnpin for FactIndex
impl !UnwindSafe for FactIndex
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