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
104
105
//! A portable object store that caches plain Rust values on the heap, over pluggable backends
//! from bare-metal to hosted systems.
//!
//! Objects have a name and a type. They are read from the backend on first use and kept in RAM
//! within a budget. Changes stay in RAM until you flush them, so the writes to storage only happen
//! when and where you choose. No function waits: a call that can't be done now returns `Ok(None)`.
//!
//! - [`ObjShelf`]: mounting, the RAM budget, locking, durability, and an example.
//! - Objects: [`list`], [`get`], [`insert`], [`get_or_insert_with`], [`remove`], [`with`] and
//! [`with_mut`].
//! - Writes: [`flush`] and [`flush_object`]. Storage: [`usage`] and [`wear`].
//! - Backends: [`backend::nor`], NOR flash through any blocking `NorFlash` driver, and
//! `backend::fs`, a directory of files (feature `fs`).
//!
//! # Features
//!
//! - `fs`: the file system backend, for Unix. It needs `std`. Without it the crate is `no_std`
//! and only needs `alloc`.
//!
//! The [repository](https://github.com/MF-Room/objshelf) has the README, with timings and a
//! lifetime estimate for NOR flash, and two examples of a whole app: `examples/rtic_nor`, RTIC 2
//! on an STM32F413 with SPI NOR, and `examples/std_fs.rs`, the same app on std.
extern crate alloc;
use PhantomData;
use GetSize;
use ;
pub use ;
/// The lock trait of RTIC 2 (`rtic::Mutex`): the functions of this crate take anything that
/// implements it. Implement it to share an `ObjShelf` without RTIC.
pub use Mutex;
/// Longest name of an object, in bytes of UTF-8. A name is written again with each write of its
/// object, and this keeps it in the first page of the object on NOR flash, so mount reads one page
/// per object to find the names.
pub const MAX_NAME_LEN: usize = 64;
/// Identifier of an object stored in a [`backend::Backend`].
;
/// Types that can be kept in an [`ObjShelf`]: serialized when they go to the backend, and measured
/// in RAM with [`GetSize`] from the `get-size2` crate (`#[derive(GetSize)]`). `Send`, as RTIC
/// shares resources between tasks of different priorities.
/// Typed handle to an object of type `T`, obtained from [`get`] or [`insert`].
///
/// A handle is a plain identifier: copying it is free, and it can be stored anywhere (statics, other
/// tasks). The object itself is only reached through the `with*` functions, such as [`with`].
/// Errors of [`ObjShelf`], generic over the backend's error `E`.