Trait epserde::deser::Deserialize
source · pub trait Deserialize: TypeHash + ReprHash + DeserializeInner {
// Required methods
fn deserialize_full(backend: &mut impl ReadNoStd) -> Result<Self>;
fn deserialize_eps(backend: &[u8]) -> Result<Self::DeserType<'_>>;
// Provided methods
fn load_full(path: impl AsRef<Path>) -> Result<Self> { ... }
fn load_mem<'a>(
path: impl AsRef<Path>
) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>> { ... }
fn load_mmap<'a>(
path: impl AsRef<Path>,
flags: Flags
) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>> { ... }
fn mmap<'a>(
path: impl AsRef<Path>,
flags: Flags
) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>> { ... }
}
Expand description
Main deserialization trait. It is separated from DeserializeInner
to
avoid that the user modify its behavior, and hide internal serialization
methods.
It provides several convenience methods to load or map into memory
structures that have been previously serialized. See, for example,
Deserialize::load_full
, Deserialize::load_mem
, and Deserialize::mmap
.
Required Methods§
sourcefn deserialize_full(backend: &mut impl ReadNoStd) -> Result<Self>
fn deserialize_full(backend: &mut impl ReadNoStd) -> Result<Self>
Fully deserialize a structure of this type from the given backend.
sourcefn deserialize_eps(backend: &[u8]) -> Result<Self::DeserType<'_>>
fn deserialize_eps(backend: &[u8]) -> Result<Self::DeserType<'_>>
ε-copy deserialize a structure of this type from the given backend.
Provided Methods§
sourcefn load_full(path: impl AsRef<Path>) -> Result<Self>
fn load_full(path: impl AsRef<Path>) -> Result<Self>
Commodity method to fully deserialize from a file.
sourcefn load_mem<'a>(
path: impl AsRef<Path>
) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>>
fn load_mem<'a>( path: impl AsRef<Path> ) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>>
Load a file into heap-allocated memory and ε-deserialize a data structure from it,
returning a MemCase
containing the data structure and the
memory. Excess bytes are zeroed out.
The allocated memory will have MemoryAlignment
as alignment: types with
a higher alignment requirement will cause an alignment error.
sourcefn load_mmap<'a>(
path: impl AsRef<Path>,
flags: Flags
) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>>
fn load_mmap<'a>( path: impl AsRef<Path>, flags: Flags ) -> Result<MemCase<<Self as DeserializeInner>::DeserType<'a>>>
Object Safety§
Implementors§
impl<T: TypeHash + ReprHash + DeserializeInner> Deserialize for T
Blanket implementation that prevents the user from overwriting the
methods in Deserialize
.
This implementation checks the header written
by the blanket implementation of crate::ser::Serialize
and then delegates to
DeserializeInner::_deserialize_full_inner
or
DeserializeInner::_deserialize_eps_inner
.