Allow read_slice to return a Vec

This commit is contained in:
Julien Cretin
2022-06-03 11:16:43 +02:00
parent 85fe9cd29d
commit f57126634b
5 changed files with 29 additions and 24 deletions

View File

@@ -14,6 +14,8 @@
//! Flash storage abstraction.
use alloc::borrow::Cow;
/// Represents a byte position in a storage.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct StorageIndex {
@@ -60,7 +62,7 @@ pub trait Storage {
/// Reads a byte slice from the storage.
///
/// The `index` must designate `length` bytes in the storage.
fn read_slice(&self, index: StorageIndex, length: usize) -> StorageResult<&[u8]>;
fn read_slice(&self, index: StorageIndex, length: usize) -> StorageResult<Cow<[u8]>>;
/// Writes a word slice to the storage.
///