pub struct EnforcementEventWriter { /* private fields */ }Expand description
The enforcement event writer. Ties together sequence allocation, hash chaining, and store persistence into a single write path.
One writer per store lifetime. Not Clone — the seq counter and prev_hash chain are stateful.
Implementations§
Source§impl EnforcementEventWriter
impl EnforcementEventWriter
Sourcepub async fn new(store: &Store) -> Result<Self>
pub async fn new(store: &Store) -> Result<Self>
Initialize the writer from store state.
Loads the current seq counter, installation_id, and the hash of the last event in the stream (for chain continuity).
Sourcepub async fn write(
&mut self,
store: &Store,
event_type: EnforcementEventType,
subject_kind: SubjectKind,
subject_key: String,
agent_type: String,
receipt_id: Option<String>,
decision_reason_code: String,
decision_basis_hash: Option<String>,
) -> Result<EnforcementEvent>
pub async fn write( &mut self, store: &Store, event_type: EnforcementEventType, subject_kind: SubjectKind, subject_key: String, agent_type: String, receipt_id: Option<String>, decision_reason_code: String, decision_basis_hash: Option<String>, ) -> Result<EnforcementEvent>
Write an enforcement event to the store.
Allocates a seq_no (persisted before event write), computes the
hash chain, and writes the event as JSON under enforcement:event:{seq_no}.
Returns the written event (with computed hashes) or an error.
Sourcepub fn installation_id(&self) -> &str
pub fn installation_id(&self) -> &str
Return the current installation ID.
Sourcepub fn current_seq(&self) -> u64
pub fn current_seq(&self) -> u64
Return the current sequence number (last allocated).
Sourcepub async fn detect_and_record_gap(
&mut self,
store: &Store,
gap_start_ms: u64,
gap_end_ms: u64,
cause: GapCause,
) -> Result<EnforcementEvent>
pub async fn detect_and_record_gap( &mut self, store: &Store, gap_start_ms: u64, gap_end_ms: u64, cause: GapCause, ) -> Result<EnforcementEvent>
Detect gaps in the event stream and emit a RecordingGap event.
Called on writer initialization when the seq counter is ahead of the last stored event (indicating a crash between seq allocation and event write).
Auto Trait Implementations§
impl Freeze for EnforcementEventWriter
impl RefUnwindSafe for EnforcementEventWriter
impl Send for EnforcementEventWriter
impl Sync for EnforcementEventWriter
impl Unpin for EnforcementEventWriter
impl UnsafeUnpin for EnforcementEventWriter
impl UnwindSafe for EnforcementEventWriter
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more