Add justification for Cow usage

This commit is contained in:
Julien Cretin
2022-06-03 17:03:06 +02:00
parent f57126634b
commit 0f368f0b48

View File

@@ -62,6 +62,9 @@ pub trait Storage {
/// Reads a byte slice from the storage. /// Reads a byte slice from the storage.
/// ///
/// The `index` must designate `length` bytes in the storage. /// The `index` must designate `length` bytes in the storage.
///
/// Note that we use `Cow` just because it derefs to `[u8]`. We don't really need the fact that
/// one can convert it to a `Vec`. In particular we don't do it in the store implementation.
fn read_slice(&self, index: StorageIndex, length: usize) -> StorageResult<Cow<[u8]>>; fn read_slice(&self, index: StorageIndex, length: usize) -> StorageResult<Cow<[u8]>>;
/// Writes a word slice to the storage. /// Writes a word slice to the storage.