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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! Pure Rust implementation of the littlefs v2 on-disk format.
//!
//! Inspired by littlefs. This is independent Rust code with interoperability
//! against upstream littlefs treated as a design constraint.
//!
//! The public API is centered on a synchronous [`BlockDevice`] trait plus
//! mounted read-only and mutable filesystem handles. Core library code supports
//! `no_std + alloc`; the default `std` feature adds [`FileBlockDevice`] for
//! local-file backed images in tests and host-side tools.
//!
//! # Example
//!
//! ```no_run
//! use littlefs_rust::{Config, FileBlockDevice, FileOptions, Filesystem};
//!
//! fn main() -> littlefs_rust::Result<()> {
//! let cfg = Config {
//! block_size: 512,
//! block_count: 4096,
//! };
//!
//! let path = std::env::temp_dir().join("littlefs-rust-doc-example.img");
//! let mut device = FileBlockDevice::create_erased(&path, cfg)?;
//! Filesystem::format_device(&mut device)?;
//!
//! let mut fs = Filesystem::mount_device_mut(device)?;
//! fs.create_dir("/logs")?;
//!
//! let mut file = fs.open_file(
//! "/logs/current.txt",
//! FileOptions::new()
//! .create(true)
//! .write(true)
//! .append(true),
//! )?;
//! file.write_all(b"boot ok\n")?;
//! file.sync()?;
//! file.close()?;
//!
//! let device = fs.into_device();
//! let ro = Filesystem::mount_device(&device)?;
//! assert_eq!(ro.read_file("/logs/current.txt")?, b"boot ok\n");
//!
//! let _ = std::fs::remove_file(path);
//! Ok(())
//! }
//! ```
//!
//! # Main Entry Points
//!
//! - [`Filesystem::format_device`] formats a block device.
//! - [`Filesystem::mount_device`] mounts a borrowed block device read-only.
//! - [`Filesystem::mount_device_mut`] mounts an owned block device for writes.
//! - [`FilesystemOptions`] configures littlefs-style cache, program, limit,
//! block-cycle, and inline-file policy.
//! - [`FileOptions`] configures open-file handles for read, write, append,
//! create, create-new, and truncate behavior.
//!
//! # Interoperability
//!
//! The repository's default test suite uses real image bytes and compares
//! filesystem-visible behavior with the bundled upstream C littlefs
//! implementation whenever a matching oracle exists. See `tests/README.md` in
//! the repository for the current compatibility matrix.
//!
//! # Internal Layout
//!
//! The crate is intentionally split by littlefs layers:
//!
//! - `format` knows about raw on-disk numbers, tags, endian quirks, and CRCs.
//! - `commit` writes metadata block commits using the same tag/CRC machinery.
//! - `metadata` turns committed metadata logs into semantic file records.
//! - `fs` exposes read-only and mounted mutable filesystem APIs.
//! - `writer` contains explicit full-image builder/editor utilities for
//! fixtures, host tools, and interop tests.
extern crate alloc;
extern crate std;
pub use FileBlockDevice;
pub use ;
pub use ;
pub use ;
pub use ;