Skip to main content

Crate axess_events

Crate axess_events 

Source
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

FeatureDefaultEffect
serdeyesAll envelope types implement Serialize / Deserialize.
rkyvnoAll envelope types implement rkyv Archive / Serialize / Deserialize. Required for org-internal binary streams (Iggy, replay archives).
fullnoBoth 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) and EventPayload (the trait every domain payload type implements).
sink
EventSink, the trait every producer rides, plus the standard sinks (NoopEventSink and LogAndSwallow).
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§

ArchivedEvent
An archived Event
DeviceId
Device identifier, sibling to UserId / TenantId. axess-minted: cryptographic opacity is the security contract, so prefer Self::new over Self::from_namespaced_str in production paths.
Event
Cross-cutting event envelope. Domain-specific payload P lives in the body field, wrapped in EventBody to allow either clear payloads or opaque encrypted bytes.
EventId
Event identifier for Event<P> envelopes. axess-minted: UUID v4 random from a DST-injected SecureRng. Sortability of events comes from Event::time_micros and from domain time-stamped fields, not from the id.
EventResolver
The resolver for an archived Event
SessionId
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.
TenantId
Tenant identifier. Scopes principals and events to a multi-tenant boundary. Adopter-supplied: see Self::from_uuid for direct UUID adoption, Self::from_namespaced_str for v5 mapping of non-UUID identifiers, Self::SYSTEM for the reserved platform-operator sentinel.
UserId
User (subject / principal) identifier. Adopter-supplied, same constructor surface as TenantId. Distinct Self::SYSTEM sentinel from the tenant so applications installing real rows for both don’t collapse them.

Enums§

ArchivedEventBody
An archived EventBody
EventBody
Either a clear typed payload or an opaque encrypted blob.
EventBodyResolver
The resolver for an archived EventBody