Trait Event

Source
pub trait Event: Sized + Encode {
    // Required methods
    fn module_name() -> &'static str;
    fn code(&self) -> u32;

    // Provided method
    fn into_event_tag(self) -> EventTag { ... }
}
Expand description

An event emitted by the runtime.

This trait can be derived:

const MODULE_NAME: &str = "my-module";
#[derive(Clone, Debug, cbor::Encode, Event)]
#[cbor(untagged)]
#[sdk_event(autonumber)] // `module_name` meta is required if `MODULE_NAME` isn't in scope
enum MyEvent {
   Greeting(String),      // autonumbered to 0
   #[sdk_event(code = 2)] // manually numbered to 2 (`code` is required if not autonumbering)
   DontPanic,
   Salutation {           // autonumbered to 1
       plural: bool,
   }
}

Required Methods§

Source

fn module_name() -> &'static str

Name of the module that emitted the event.

Source

fn code(&self) -> u32

Code uniquely identifying the event.

Provided Methods§

Source

fn into_event_tag(self) -> EventTag

Converts an event into an event tag.

§Key
<module (variable size bytes)> <code (big-endian u32)>
§Value

CBOR-serialized event value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Event for ()

Source§

fn module_name() -> &'static str

Source§

fn code(&self) -> u32

Implementors§

Source§

impl Event for oasis_runtime_sdk::modules::accounts::Event

Source§

impl Event for oasis_runtime_sdk::modules::consensus::Event

Source§

impl Event for oasis_runtime_sdk::modules::consensus_accounts::Event

Source§

impl Event for oasis_runtime_sdk::modules::core::Event

Source§

impl Event for oasis_runtime_sdk::modules::rofl::Event