odra_types/
event.rs

1//! Events interface and errors.
2
3use alloc::string::String;
4
5#[cfg(not(target_arch = "wasm32"))]
6use crate::contract_def::Event as Schema;
7
8/// Event interface
9pub trait OdraEvent {
10    /// Emits &self in the current environment.
11    fn emit(self);
12    /// Returns the event name.
13    fn name() -> String;
14    #[cfg(not(target_arch = "wasm32"))]
15    /// Returns the event schema.
16    fn schema() -> Schema;
17}
18
19/// Event-related errors.
20#[derive(Debug, PartialEq, Eq, PartialOrd)]
21pub enum EventError {
22    /// The type of event is different than expected.
23    UnexpectedType(String),
24    /// Index of the event is out of bounds.
25    IndexOutOfBounds,
26    /// Formatting error while deserializing.
27    Formatting,
28    /// Unexpected error while deserializing.
29    Parsing
30}