1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Safe Rust API for the LittleFS embedded filesystem.
//!
//! Built on [`littlefs-rust-core`](https://crates.io/crates/littlefs-rust-core), a
//! function-by-function Rust port of the
//! [C littlefs](https://github.com/littlefs-project/littlefs). No C toolchain required.
//!
//! # Quick start
//!
//! ```rust
//! use littlefs_rust::{Config, Filesystem, RamStorage};
//!
//! let mut storage = RamStorage::new(512, 128);
//! let config = Config::new(512, 128);
//!
//! Filesystem::format(&mut storage, &config).unwrap();
//! let fs = Filesystem::mount(storage, config).map_err(|(e, _)| e).unwrap();
//!
//! fs.write_file("/hello.txt", b"Hello, littlefs!").unwrap();
//! let data = fs.read_to_vec("/hello.txt").unwrap();
//! assert_eq!(data, b"Hello, littlefs!");
//!
//! fs.unmount().unwrap();
//! ```
//!
//! # Architecture
//!
//! The crate uses interior mutability ([`RefCell`](core::cell::RefCell)) so that
//! [`Filesystem`] methods take `&self`. Each operation borrows the internal state only
//! for the duration of one core call, then releases it. This enables multiple open
//! files, interleaved file and directory operations, and reading files while iterating
//! directories — all without conflict.
//!
//! [`File`] and [`ReadDir`] hold a shared reference to the [`Filesystem`] and implement
//! [`Drop`] for RAII close.
extern crate alloc;
pub use Config;
pub use ReadDir;
pub use Error;
pub use File;
pub use Filesystem;
pub use ;
pub use RamStorage;
pub use Storage;