app

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

commit 7a800dff8d5989703b4f5955009ec177a376342a
parent fa13454bf172f9e4038e1210183e4981f688c350
Author: triesap <triesap@radroots.dev>
Date:   Mon, 19 Jan 2026 21:21:25 +0000

app: add tangle client adapter stub

- introduce tangle client trait and stub impl
- define not-implemented error for tangle client
- export tangle adapter from app module
- add unit tests for stub error behavior

Diffstat:
Mapp/src/lib.rs | 2++
Aapp/src/tangle.rs | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/app/src/lib.rs b/app/src/lib.rs @@ -9,6 +9,7 @@ mod health; mod init; mod keystore; mod notifications; +mod tangle; mod entry; pub use app::App; @@ -43,6 +44,7 @@ pub use keystore::{ AppKeystoreResult, }; pub use notifications::{AppNotifications, AppNotificationsError, AppNotificationsResult}; +pub use tangle::{AppTangleClient, AppTangleClientStub, AppTangleError, AppTangleResult}; pub use config::{ app_config_default, app_config_from_env, diff --git a/app/src/tangle.rs b/app/src/tangle.rs @@ -0,0 +1,55 @@ +#![forbid(unsafe_code)] + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum AppTangleError { + NotImplemented, +} + +pub type AppTangleResult<T> = Result<T, AppTangleError>; + +impl AppTangleError { + pub const fn message(self) -> &'static str { + match self { + AppTangleError::NotImplemented => "error.app.tangle.not_implemented", + } + } +} + +impl std::fmt::Display for AppTangleError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.message()) + } +} + +impl std::error::Error for AppTangleError {} + +pub trait AppTangleClient { + fn init(&self) -> AppTangleResult<()>; +} + +pub struct AppTangleClientStub; + +impl AppTangleClientStub { + pub fn new() -> Self { + Self + } +} + +impl AppTangleClient for AppTangleClientStub { + fn init(&self) -> AppTangleResult<()> { + Err(AppTangleError::NotImplemented) + } +} + +#[cfg(test)] +mod tests { + use super::{AppTangleClient, AppTangleClientStub, AppTangleError}; + + #[test] + fn tangle_stub_reports_not_implemented() { + let client = AppTangleClientStub::new(); + let err = client.init().expect_err("not implemented"); + assert_eq!(err, AppTangleError::NotImplemented); + assert_eq!(err.to_string(), "error.app.tangle.not_implemented"); + } +}