Skip to main content

fs_core/
lib.rs

1//! In-memory filesystem implementation shared by every Monaka component.
2//!
3//! A single `Fs` type is exposed in two flavours via the `thread-safe`
4//! feature flag:
5//!
6//! - `thread-safe` (requires `std`): backed by `DashMap` plus
7//!   `Arc<RwLock<Inode>>`, used by host-side wasmtime integrations that
8//!   need `Send + Sync`.
9//! - default: backed by `RefCell<HashMap>` or `RefCell<BTreeMap>` plus
10//!   `Rc<RefCell<Inode>>`, used by the WASI components.
11//!
12//! Both flavours share one `&self` API, so consumers only need to pick
13//! the feature flag that matches their target.
14
15#![cfg_attr(not(feature = "std"), no_std)]
16
17extern crate alloc;
18
19// Logging support: conditional compilation for zero-cost when disabled
20#[cfg(feature = "logging")]
21pub use log::{debug, error, info, trace, warn};
22
23#[cfg(not(feature = "logging"))]
24#[macro_export]
25macro_rules! trace {
26    ($($t:tt)*) => {};
27}
28
29#[cfg(not(feature = "logging"))]
30#[macro_export]
31macro_rules! debug {
32    ($($t:tt)*) => {};
33}
34
35#[cfg(not(feature = "logging"))]
36#[macro_export]
37macro_rules! info {
38    ($($t:tt)*) => {};
39}
40
41#[cfg(not(feature = "logging"))]
42#[macro_export]
43macro_rules! warn {
44    ($($t:tt)*) => {};
45}
46
47#[cfg(not(feature = "logging"))]
48#[macro_export]
49macro_rules! error {
50    ($($t:tt)*) => {};
51}
52
53mod error;
54mod fs;
55mod handle;
56mod inode;
57pub mod snapshot;
58mod storage;
59mod time;
60mod types;
61
62// Re-export public API
63pub use error::FsError;
64pub use fs::Fs;
65pub use inode::{FileContent, Inode, Metadata};
66pub use storage::BlockStorage;
67pub use time::{MonotonicCounter, TimeProvider};
68pub use types::{BLOCK_SIZE, Fd, InodeId, O_APPEND, O_CREAT, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};