Expand description
Shared event vocabulary for the axess workspace and platform domains.
Event<P> is the cross-cutting envelope: id, time, tenant, kind,
subject, actor, trace context, status, body. The body is either a
clear typed payload P or an opaque EncryptedBlob; chosen by
the producer at emission time, transparent to subscribers without
the key.
Each domain defines its own payload enum implementing
EventPayload; the envelope crate stays domain-agnostic.
§Quick start
use axess_events::{Event, EventBody, EventId, EventPayload, EventStatus, KindTag};
use serde::{Serialize, Deserialize};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum DemoPayload {
Hello { who: String },
}
impl EventPayload for DemoPayload {
fn kind_tag(&self) -> KindTag {
match self {
DemoPayload::Hello { .. } => KindTag::from_static("demo.hello.v1"),
}
}
fn to_inner_json(&self) -> serde_json::Value {
match self {
DemoPayload::Hello { who } => serde_json::json!({ "who": who }),
}
}
}
let payload = DemoPayload::Hello { who: "world".into() };
let event = Event::<DemoPayload> {
id: EventId::NIL,
envelope_version: Event::<DemoPayload>::ENVELOPE_VERSION,
time_micros: 0,
tenant_id: None,
kind: payload.kind_tag(),
subject: None,
actor: None,
trace_context: None,
status: EventStatus::Info,
body: EventBody::Clear(payload),
};
assert_eq!(event.kind.as_str(), "demo.hello.v1");§Feature flags
| Feature | Default | Effect |
|---|---|---|
serde | yes | All envelope types implement Serialize / Deserialize. |
rkyv | no | All envelope types implement rkyv Archive / Serialize / Deserialize. Required for org-internal binary streams (Iggy, replay archives). |
full | no | Both serde and rkyv. |
Re-exports§
pub use encryption::AeadAlgorithm;pub use encryption::EncryptedBlob;pub use encryption::KeyId;pub use kind::EventPayload;pub use kind::KindTag;pub use sink::EventSink;pub use sink::LogAndSwallow;pub use sink::NoopEventSink;pub use sink::SinkError;pub use status::EventStatus;pub use subject::EventSubject;pub use trace::TraceContext;
Modules§
- encryption
- Payload-level encryption primitives.
- id
- Typed identifiers for the event vocabulary.
- kind
- Event taxonomy:
KindTag(wire-form discriminator) andEventPayload(the trait every domain payload type implements). - sink
EventSink, the trait every producer rides, plus the standard sinks (NoopEventSinkandLogAndSwallow).- status
EventStatus: coarse outcome bucket. Detailed reason lives in the payload.- subject
EventSubject: the entity an event is about or initiated by.- trace
TraceContext: W3C Trace Context for cross-service span correlation.
Structs§
- Archived
Event - An archived
Event - Device
Id - Device identifier, sibling to
UserId/TenantId. axess-minted: cryptographic opacity is the security contract, so preferSelf::newoverSelf::from_namespaced_strin production paths. - Event
- Cross-cutting event envelope. Domain-specific payload
Plives in thebodyfield, wrapped inEventBodyto allow either clear payloads or opaque encrypted bytes. - EventId
- Event identifier for
Event<P>envelopes. axess-minted: UUID v4 random from a DST-injectedSecureRng. Sortability of events comes fromEvent::time_microsand from domain time-stamped fields, not from the id. - Event
Resolver - The resolver for an archived
Event - Session
Id - Session identifier. axess-minted; cryptographic opacity is the
security contract. A session-id leak that revealed login time
would be a vulnerability for forensic correlation against
externally-observed events, so prefer
Self::new(UUID v4 random) over time-prefixed variants. - Tenant
Id - Tenant identifier. Scopes principals and events to a
multi-tenant boundary. Adopter-supplied: see
Self::from_uuidfor direct UUID adoption,Self::from_namespaced_strfor v5 mapping of non-UUID identifiers,Self::SYSTEMfor the reserved platform-operator sentinel. - UserId
- User (subject / principal) identifier. Adopter-supplied, same
constructor surface as
TenantId. DistinctSelf::SYSTEMsentinel from the tenant so applications installing real rows for both don’t collapse them.
Enums§
- Archived
Event Body - An archived
EventBody - Event
Body - Either a clear typed payload or an opaque encrypted blob.
- Event
Body Resolver - The resolver for an archived
EventBody