mod builder;
use std::convert::Infallible;
pub use builder::*;
mod typed;
use cap_sdk_core::transaction::{DetailValue, IndefiniteEvent};
pub use typed::*;
pub trait IntoEvent {
fn operation(&self) -> Option<&'static str> {
None
}
fn details(&self) -> Vec<(String, DetailValue)>;
}
impl IntoEvent for Vec<(String, DetailValue)> {
fn details(&self) -> Vec<(String, DetailValue)> {
self.clone()
}
}
pub trait TryFromEvent: Sized {
type Error;
fn try_from_event(event: impl Into<IndefiniteEvent>) -> Result<Self, Self::Error>;
}
impl TryFromEvent for Vec<(String, DetailValue)> {
type Error = Infallible;
fn try_from_event(event: impl Into<IndefiniteEvent>) -> Result<Self, Self::Error> {
let event = event.into();
Ok(event.details)
}
}