memory_file_system/lib.rs
1//! In-RAM file system for device nodes, named pipes, and directory hierarchies.
2//!
3//! `memory_file_system` implements [`::file_system::FileSystemOperations`] entirely in RAM
4//! without touching persistent flash storage. It is designed to be mounted at `/devices`
5//! so that device nodes, pipes, and sub-directories created at boot do not cause flash
6//! writes or persist stale inode mappings across reboots.
7//!
8//! Regular file contents are not supported: [`::file_system::FileSystemOperations::lookup_file`]
9//! and [`::file_system::BaseOperations`] I/O methods return
10//! [`::file_system::IoErrorKind::Unsupported`].
11//!
12//! # Memory Layout and Per-Node Cost
13//!
14//! All nodes are stored in a single flat `Vec<Option<Node>>` indexed by a 32-bit node index,
15//! with each node holding its parent index, a generation counter (to detect stale directory
16//! handles after node removal and slot reuse), a compact boxed name (`Box<str>`), and stored
17//! metadata fields (no per-node `BTreeMap` or file content buffer). Because `Box<str>` carries
18//! a non-null pointer niche, `Option<Node>` adds zero discriminant overhead.
19//!
20//! Exact per-node RAM cost (excluding `Vec` capacity slack and heap allocator metadata):
21//! - **32-bit targets** (for example Cortex-M4 with 256 KB RAM): **64 bytes** per `Option<Node>`
22//! plus `name.len()` heap bytes for the node name (`0` heap bytes for the root directory).
23//! - **64-bit targets** (for example x86_64 host): **72 bytes** per `Option<Node>`
24//! plus `name.len()` heap bytes for the node name (`0` heap bytes for the root directory).
25
26#![no_std]
27
28extern crate alloc;
29
30mod attributes;
31mod directory;
32mod file_system;
33mod node;
34
35pub use file_system::FileSystem;