Trait oasis_contract_sdk::event::Event

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

    // Provided method
    fn into_raw(self) -> Event { ... }
}
Expand description

An event emitted by the contract.

This trait can be derived:

#[derive(Clone, Debug, cbor::Encode, Event)]
#[cbor(untagged)]
#[sdk_event(autonumber)]
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(&self) -> &str

Name of the module that emitted the event.

source

fn code(&self) -> u32

Code uniquely identifying the event.

Provided Methods§

source

fn into_raw(self) -> Event

Converts an event into the raw event type that can be emitted from the contract.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Event for Event

source§

fn module_name(&self) -> &str

source§

fn code(&self) -> u32

source§

fn into_raw(self) -> Event

Implementors§