StoreBackend::Data: don't require Sized

This commit is contained in:
Astro 2020-12-11 21:09:08 +01:00
parent 4db466ffc4
commit c3e294d211

View File

@ -1,6 +1,6 @@
#![no_std] #![no_std]
use core::{mem::size_of, str}; use core::str;
use byteorder::{ByteOrder, BigEndian}; use byteorder::{ByteOrder, BigEndian};
#[cfg(feature = "postcard-values")] #[cfg(feature = "postcard-values")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -14,12 +14,12 @@ mod test;
/// Backend interface for `Store` /// Backend interface for `Store`
pub trait StoreBackend { pub trait StoreBackend {
type Data: Sized + AsRef<[u8]>; type Data: ?Sized + AsRef<[u8]>;
/// Memory-mapped /// Memory-mapped
fn data(&self) -> &Self::Data; fn data(&self) -> &Self::Data;
fn len(&self) -> usize { fn len(&self) -> usize {
size_of::<Self::Data>() self.data().as_ref().len()
} }
type Error; type Error;