MARS documentation
Rust librariesmars-protocol

mars-protocol · events

Public declarations and documentation for mars-protocol::events.

Package: mars-protocol · Workspace version: 0.1.0 · Module: events

This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.

events::MarsEvent

A notification event emitted by a MARS registry. Per MARS Specification Section 13.3.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct MarsEvent {
/// The type of event.

pub event_type: EventType,
/// Unique event identifier.

pub event_id: String,
/// When the event occurred.

pub timestamp: chrono::DateTime<chrono::Utc>,
/// DID of the registry that emitted the event.

pub registry_did: String,
/// Event-specific payload.

pub payload: EventPayload
}

Source line: 12.

events::EventType

The kind of event that occurred. Per MARS Specification Section 13.1.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
pub enum EventType {
    /// New entry registered.
    #[serde(rename = "entry.created")]
    EntryCreated,
    /// Entry version updated.
    #[serde(rename = "entry.updated")]
    EntryUpdated,
    /// Entry revoked.
    #[serde(rename = "entry.revoked")]
    EntryRevoked,
    /// Ownership transferred.
    #[serde(rename = "entry.transferred")]
    EntryTransferred,
    /// New attestation attached.
    #[serde(rename = "entry.attested")]
    EntryAttested,
    /// Malicious report filed.
    #[serde(rename = "entry.reported")]
    EntryReported,
    /// Bond slashed.
    #[serde(rename = "bond.slashed")]
    BondSlashed,
    /// Federation sync completed.
    #[serde(rename = "federation.sync")]
    FederationSync,
}

Source line: 29.

events::EventType::as_str

Returns the dot-notation event name string.

pub fn as_str(&self) -> &'static str;

Source line: 58.

events::EventType::all

Returns all 8 event types.

pub fn all() -> &'static [Self];

Source line: 72.

events::EventPayload

Event-specific payload.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct EventPayload {
/// DID of the affected entry.

pub entry_did: String,
/// Entry type (when applicable).

#[serde(skip_serializing_if = "Option::is_none")]
pub entry_type: Option<String>,
/// Version (when applicable).

#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
/// Publisher DID.

#[serde(skip_serializing_if = "Option::is_none")]
pub publisher_did: Option<String>,
/// Additional event-specific data.

#[serde(skip_serializing_if = "Option::is_none")]
pub detail: Option<serde_json::Value>
}

Source line: 96.

events::SubscriptionFilter

WebSocket subscription filter. Per MARS Specification Section 12.4.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionFilter {
/// Filter by entry types.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub entry_types: Vec<String>,
/// Filter by namespaces.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub namespaces: Vec<String>,
/// Filter by event types.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub events: Vec<String>,
/// Filter by specific entry DIDs.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub entry_dids: Vec<String>
}

Source line: 118.

events::SubscriptionMessage

WebSocket subscription message.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionMessage {
/// Action: "subscribe" or "unsubscribe".

pub action: String,
/// Subscription filters.

pub filters: SubscriptionFilter
}

Source line: 137.

Source provenance

Source: mars-protocol/src/events.rs · SHA-256 4c066acceaf55cd4a0d7eb5efb701f9e9f1fe389e41320747c8e5fce6c25d7d2. Package overview.

On this page