pub struct Event {
pub kind: EventKind,
pub actor: String,
pub subject: String,
pub payload: Value,
}Expand description
The input half of an audit entry — everything the caller supplies.
Once persisted, the audit log attaches position, prev_hash, and
this_hash, producing a StoredEvent.
Fields§
§kind: EventKind§actor: StringAgent that triggered this event (sender, org admin, scanner). Empty string is permitted for system-level events.
subject: StringLogical subject of the event: transfer_id, agent_id, etc. Empty means the actor itself is the subject.
payload: ValueStructured payload. Must be a JSON object; arrays/primitives at the top level are rejected to avoid ambiguous canonical output.
Implementations§
Source§impl Event
impl Event
pub fn new( kind: EventKind, actor: impl Into<String>, subject: impl Into<String>, payload: Value, ) -> Self
Sourcepub fn canonical_bytes(
&self,
ts: OffsetDateTime,
prev_hash: &str,
) -> AuditResult<Vec<u8>>
pub fn canonical_bytes( &self, ts: OffsetDateTime, prev_hash: &str, ) -> AuditResult<Vec<u8>>
Produce the canonical byte string that will be hashed into the chain. Format:
{"kind":"...","actor":"...","subject":"...","payload":<canonical>,"ts":"RFC3339","prev":"..."}Key order is fixed; payload is canonicalized recursively (sorted
object keys, no whitespace). This bytestring uniquely determines
this_hash given a stable input.
Sourcepub fn compute_hash(
&self,
ts: OffsetDateTime,
prev_hash: &str,
) -> AuditResult<String>
pub fn compute_hash( &self, ts: OffsetDateTime, prev_hash: &str, ) -> AuditResult<String>
Compute the hash an event would carry given timestamp + previous chain head.