app

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

commit d76d6f3bfc6c02b7cdd693b5ae21f6ba2bfb96e3
parent 0fcc8dc304631c4140ae8d5ca81a756635cc6b71
Author: triesap <triesap@radroots.dev>
Date:   Mon, 19 Jan 2026 07:12:44 +0000

app-utils: add file path types

- add file bytes format enum
- add file and blob path structs
- add web file path enum wrapper
- add unit tests for file types

Diffstat:
Mcrates/utils/src/lib.rs | 5+++--
Mcrates/utils/src/types.rs | 52++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs @@ -27,6 +27,7 @@ pub use path::{ pub use text::{str_cap, str_cap_words, text_dec, text_enc, ROOT_SYMBOL}; pub use time::{time_now_ms, time_now_s}; pub use types::{ - resolve_err, resolve_ok, ResolveError, ResultBool, ResultId, ResultObj, ResultPass, - ResultPublicKey, ResultSecretKey, ResultsList, + resolve_err, resolve_ok, FileBytesFormat, FilePath, FilePathBlob, FileMimeType, ResolveError, + ResultBool, ResultId, ResultObj, ResultPass, ResultPublicKey, ResultSecretKey, ResultsList, + WebFilePath, }; diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs @@ -5,6 +5,35 @@ use crate::error::RadrootsAppUtilsError; pub type ResolveError<T> = Result<T, RadrootsAppUtilsError>; #[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum FileBytesFormat { + Kb, + Mb, + Gb, +} + +pub type FileMimeType = String; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct FilePath { + pub file_path: String, + pub file_name: String, + pub mime_type: FileMimeType, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct FilePathBlob { + pub blob_path: String, + pub blob_name: String, + pub mime_type: Option<FileMimeType>, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum WebFilePath { + File(FilePath), + Blob(FilePathBlob), +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ResultPass { pub pass: bool, } @@ -53,8 +82,8 @@ pub fn resolve_err<T>(err: RadrootsAppUtilsError) -> ResolveError<T> { #[cfg(test)] mod tests { use super::{ - resolve_err, resolve_ok, ResultBool, ResultId, ResultObj, ResultPass, ResultPublicKey, - ResultSecretKey, ResultsList, + resolve_err, resolve_ok, FileBytesFormat, FilePath, FilePathBlob, ResultBool, ResultId, + ResultObj, ResultPass, ResultPublicKey, ResultSecretKey, ResultsList, WebFilePath, }; use crate::error::RadrootsAppUtilsError; @@ -100,4 +129,23 @@ mod tests { }; assert_eq!(secret_key.secret_key, "sec"); } + + #[test] + fn file_path_types_store_values() { + let path = FilePath { + file_path: "path".to_string(), + file_name: "name".to_string(), + mime_type: "text/plain".to_string(), + }; + let blob = FilePathBlob { + blob_path: "blob".to_string(), + blob_name: "blob.bin".to_string(), + mime_type: None, + }; + let file_path = WebFilePath::File(path.clone()); + let blob_path = WebFilePath::Blob(blob.clone()); + assert_eq!(file_path, WebFilePath::File(path)); + assert_eq!(blob_path, WebFilePath::Blob(blob)); + assert_eq!(FileBytesFormat::Kb, FileBytesFormat::Kb); + } }