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§
sourcefn module_name() -> &'static str
fn module_name() -> &'static str
Name of the module that emitted the event.
Provided Methods§
sourcefn into_event_tag(self) -> EventTag
fn into_event_tag(self) -> EventTag
Object Safety§
This trait is not object safe.