Trait epserde::ser::SerializeInner
source · pub trait SerializeInner {
const IS_ZERO_COPY: bool;
const ZERO_COPY_MISMATCH: bool;
// Required method
fn _serialize_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>;
}
Expand description
Inner trait to implement serialization of a type. This trait exists
to separate the user-facing Serialize
trait from the low-level
serialization mechanism of SerializeInner::_serialize_inner
. Moreover,
it makes it possible to behave slighly differently at the top
of the recursion tree (e.g., to write the endianness marker), and to prevent
the user from modifying the methods in Serialize
.
The user should not implement this trait directly, but rather derive it.
Required Associated Constants§
sourceconst IS_ZERO_COPY: bool
const IS_ZERO_COPY: bool
Inner constant used by the derive macros to keep
track recursively of whether the type
satisfies the conditions for being zero-copy. It is checked
at runtime against the trait implemented by the type, and
if a ZeroCopy
type has this constant set to false
serialization will panic.
sourceconst ZERO_COPY_MISMATCH: bool
const ZERO_COPY_MISMATCH: bool
Inner constant used by the derive macros to keep
track of whether all fields of a type are zero-copy
but neither the attribute #[zero_copy]
nor the attribute #[deep_copy]
was specified. It is checked at runtime, and if it is true
a warning will be issued, as the type could be zero-copy,
which would be more efficient.
Required Methods§
sourcefn _serialize_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
fn _serialize_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
Serialize this structure using the given backend.