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§
Provided Associated Constants§
Provided Methods§
Sourcefn upcast(&self) -> Result<EventData, CborValueError>
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".