app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 63aa6d26f5afa24f079451ff7de5e0787bfc2f99
parent d81e25f4557fe4d4851239958d2ce6559aa4edfc
Author: triesap <triesap@radroots.dev>
Date:   Sun, 18 Jan 2026 23:38:24 +0000

app-core: add client fs error map

- add fs module scaffold to radroots-app-core
- define RadrootsClientFsError with message mapping
- implement Display/Error for fs error enum
- cover fs error messages with unit tests

Diffstat:
Acrates/core/src/fs/error.rs | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/core/src/fs/mod.rs | 3+++
Mcrates/core/src/lib.rs | 1+
3 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/crates/core/src/fs/error.rs b/crates/core/src/fs/error.rs @@ -0,0 +1,49 @@ +use std::fmt; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RadrootsClientFsError { + NotFound, + RequestFailure, +} + +pub type RadrootsClientFsErrorMessage = &'static str; + +impl RadrootsClientFsError { + pub const fn message(self) -> RadrootsClientFsErrorMessage { + match self { + RadrootsClientFsError::NotFound => "error.client.fs.not_found", + RadrootsClientFsError::RequestFailure => "error.client.fs.request_failure", + } + } +} + +impl fmt::Display for RadrootsClientFsError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.message()) + } +} + +impl std::error::Error for RadrootsClientFsError {} + +#[cfg(test)] +mod tests { + use super::RadrootsClientFsError; + + #[test] + fn message_matches_spec() { + let cases = [ + ( + RadrootsClientFsError::NotFound, + "error.client.fs.not_found", + ), + ( + RadrootsClientFsError::RequestFailure, + "error.client.fs.request_failure", + ), + ]; + for (err, expected) in cases { + assert_eq!(err.message(), expected); + assert_eq!(err.to_string(), expected); + } + } +} diff --git a/crates/core/src/fs/mod.rs b/crates/core/src/fs/mod.rs @@ -0,0 +1,3 @@ +pub mod error; + +pub use error::{RadrootsClientFsError, RadrootsClientFsErrorMessage}; diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs @@ -4,3 +4,4 @@ pub mod crypto; pub mod cipher; pub mod backup; pub mod datastore; +pub mod fs;