Trait oasis_runtime_sdk::event::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.

Object Safety§

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