#![no_std]
mod emitted_event;
pub use emitted_event::{EmittedEvent, TOPIC_SIZE, TypedEvent};
pub type Topic = [u8; 32];
pub enum TopicSrc<'a> {
Owned(Topic),
Shared(&'a Topic),
}
impl<'a> From<TopicSrc<'a>> for Topic {
fn from(src: TopicSrc<'a>) -> Topic {
match src {
TopicSrc::Owned(topic) => topic,
TopicSrc::Shared(topic) => *topic,
}
}
}
pub trait Event: xdrs::WriteXDR {
type Payload<'a>;
fn num_topics() -> u32
where
Self: Sized;
fn signature() -> Option<&'static Topic>
where
Self: Sized;
fn topic<'a>(&'a self, index: u32) -> Option<TopicSrc<'a>> {
let _ = index;
None
}
fn decode_payload<'a>(
bytes: &'a [u8],
) -> Result<Self::Payload<'a>, xdrs::ReadError>;
}