use alloc::vec::Vec;
use core::fmt::Debug;
use core::hash::Hash;
use derive_where::derive_where;
use wasefire_error::Error;
use wasefire_logger::MaybeFormat;
use crate::Failure;
use crate::applet::{Handlers, Memory};
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive_where(Debug, PartialEq, Eq)]
pub struct Event<B: crate::Api + ?Sized>(pub <crate::Vendor<B> as Api>::Event);
impl<B: crate::Api> From<Event<B>> for crate::Event<B> {
fn from(event: Event<B>) -> Self {
crate::Event::Vendor(event)
}
}
pub type Key<B> = <super::Vendor<B> as Api>::Key;
pub trait Api: Send {
type Event: MaybeFormat + Debug + Eq + Send;
type Key: MaybeFormat + Debug + Copy + Hash + Ord + Send;
fn key(event: &Self::Event) -> Self::Key;
fn syscall(
memory: impl Memory, handlers: impl Handlers<Self::Key>, x1: u32, x2: u32, x3: u32, x4: u32,
) -> Result<u32, Failure>;
fn callback(
memory: impl Memory, handlers: impl Handlers<Self::Key>, event: Self::Event,
params: &mut Vec<u32>,
);
fn disable(key: Self::Key) -> Result<(), Error>;
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, PartialEq, Eq)]
pub enum NoEvent {}