Skip to main content

Event

Trait Event 

Source
pub trait Event: Serialize + for<'ed> TryFrom<&'ed EventData, Error = TryFromEventError> {
    const TAG: &'static str;
    const SELECTOR: Selector = _;

    // Provided method
    fn upcast(&self) -> Result<EventData, CborValueError> { ... }
}
Expand description

Trait defining the interface for event types in the system.

This trait must be implemented by all event types in the system. It provides:

  • A unique tag for event identification
  • Serialization and deserialization capabilities
  • Type conversion between different event representations

§Examples

use ioevent::prelude::*;
use serde::{Serialize, Deserialize};

#[derive(Event, Serialize, Deserialize)]
struct UserEvent {
    user_id: u64,
    action: String,
}

Required Associated Constants§

Source

const TAG: &'static str

Unique tag identifying this event type

Provided Associated Constants§

Source

const SELECTOR: Selector = _

Selector used to match this event type

Provided Methods§

Source

fn upcast(&self) -> Result<EventData, CborValueError>

Converts the event into its raw EventData representation

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Event for EventData

Source§

const TAG: &'static str = "#"

Source§

const SELECTOR: Selector

Source§

impl Event for ProcedureCallData

Source§

const TAG: &'static str = "internal.ProcedureCall"

Source§

const SELECTOR: Selector