pub use littlefs2_core::{DirEntry, Metadata, Path, PathBuf, Result as LfsResult};
use crate::store::{ReadDirFilesState, ReadDirState};
use trussed_core::InterruptFlag;
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NoData;
pub mod ui {
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Status {
Idle,
WaitingForUserPresence,
Processing,
Error,
Custom(u8),
}
}
#[non_exhaustive]
pub struct Context<B> {
pub core: CoreContext,
pub backends: B,
}
impl<B: Default> From<CoreContext> for Context<B> {
fn from(core: CoreContext) -> Self {
Self {
core,
backends: B::default(),
}
}
}
#[non_exhaustive]
pub struct CoreContext {
pub path: PathBuf,
pub read_dir_state: Option<ReadDirState>,
pub read_dir_files_state: Option<ReadDirFilesState>,
pub interrupt: Option<&'static InterruptFlag>,
}
impl CoreContext {
pub fn new(path: PathBuf) -> Self {
Self::with_interrupt(path, None)
}
pub fn with_interrupt(path: PathBuf, interrupt: Option<&'static InterruptFlag>) -> Self {
if path.as_str() == "trussed" {
panic!("trussed is a reserved client ID");
}
Self {
path,
read_dir_state: None,
read_dir_files_state: None,
interrupt,
}
}
}