Support storing in RAM instead of flash

This permits to run without persistent storage. The benefit is that the board
doesn't implement a the syscall API in Tock. The disadvantage is that rebooting
the key will reset the storage.
This commit is contained in:
Julien Cretin
2020-03-03 23:47:32 +01:00
committed by Julien Cretin
parent 9001cbd864
commit e52a671810
7 changed files with 32 additions and 10 deletions

View File

@@ -13,6 +13,7 @@
// limitations under the License.
use super::{Index, Storage, StorageError, StorageResult};
use alloc::boxed::Box;
pub struct BufferStorage {
storage: Box<[u8]>,
@@ -230,7 +231,7 @@ impl Snapshot {
fn get(&mut self) -> Result<Box<[u8]>, usize> {
let mut snapshot = Snapshot::Ready;
std::mem::swap(self, &mut snapshot);
core::mem::swap(self, &mut snapshot);
match snapshot {
Snapshot::Armed { delay } => Err(delay),
Snapshot::Taken { storage } => Ok(storage),

View File

@@ -12,13 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[cfg(feature = "std")]
mod buffer;
mod storage;
mod store;
mod syscall;
#[cfg(feature = "std")]
pub use self::buffer::{BufferOptions, BufferStorage};
pub use self::storage::{Index, Storage, StorageError, StorageResult};
pub use self::store::{Store, StoreConfig, StoreEntry, StoreError, StoreIndex};