pub use rand_core::{CryptoRng, RngCore};
pub use crate::store::Store;
pub use crate::types::{ui, reboot};
pub use crate::types::consent;
pub trait UserInterface {
fn check_user_presence(&mut self) -> consent::Level {
consent::Level::None
}
fn set_status(&mut self, status: ui::Status) {
let _ = status;
}
fn status(&self) -> ui::Status {
ui::Status::Idle
}
fn refresh(&mut self) {}
fn uptime(&mut self) -> core::time::Duration {
Default::default()
}
fn reboot (&mut self, to: reboot::To) -> ! {
let _ = to;
loop {
continue
}
}
fn wink(&mut self, duration: core::time::Duration) {
let _ = duration;
}
}
pub unsafe trait Platform {
type R: CryptoRng + RngCore;
type S: Store;
type UI: UserInterface;
fn rng(&mut self) -> &mut Self::R;
fn store(&self) -> Self::S;
fn user_interface(&mut self) -> &mut Self::UI;
}
#[macro_export]
macro_rules! platform { (
$PlatformName:ident,
R: $Rng:ty,
S: $Store:ty,
UI: $UserInterface:ty,
) => {
pub struct $PlatformName {
rng: $Rng,
store: $Store,
user_interface: $UserInterface,
}
impl $PlatformName {
pub fn new(rng: $Rng, store: $Store, user_interface: $UserInterface) -> Self {
Self { rng, store, user_interface }
}
}
unsafe impl $crate::platform::Platform for $PlatformName {
type R = $Rng;
type S = $Store;
type UI = $UserInterface;
fn user_interface(&mut self) -> &mut Self::UI {
&mut self.user_interface
}
fn rng(&mut self) -> &mut Self::R {
&mut self.rng
}
fn store(&self) -> Self::S {
self.store
}
}
}}
pub trait Syscall {
fn syscall(&mut self);
}