pub unsafe trait ZeroCopy<C: ConfigCore>: 'static {
// Provided methods
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> ReadResult<&'de Self>
where Self: SchemaRead<'de, C, Dst = Self> + Sized { ... }
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> ReadResult<&'de mut Self>
where Self: SchemaRead<'de, C, Dst = Self> + Sized { ... }
}Expand description
Marker trait for types that can be deserialized via direct borrows from a Reader.
You should not manually implement this trait for your own type unless you absolutely
know what you're doing. The derive macros will automatically implement this trait for your type
if it is eligible for zero-copy deserialization.
§Safety
- The type must not have any invalid bit patterns, no layout requirements, no endianness checks, etc.
Provided Methods§
Sourcefn from_bytes<'de>(bytes: &'de [u8], config: C) -> ReadResult<&'de Self>where
Self: SchemaRead<'de, C, Dst = Self> + Sized,
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> ReadResult<&'de Self>where
Self: SchemaRead<'de, C, Dst = Self> + Sized,
Like crate::ZeroCopy::from_bytes, but allows the caller to provide a custom configuration.
Sourcefn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> ReadResult<&'de mut Self>where
Self: SchemaRead<'de, C, Dst = Self> + Sized,
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> ReadResult<&'de mut Self>where
Self: SchemaRead<'de, C, Dst = Self> + Sized,
Like crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.
Implementations on Foreign Types§
impl<C: ConfigCore> ZeroCopy<C> for f32where
C::ByteOrder: PlatformEndian,
impl<C: ConfigCore> ZeroCopy<C> for f64where
C::ByteOrder: PlatformEndian,
impl<C: ConfigCore> ZeroCopy<C> for i8
impl<C: ConfigCore> ZeroCopy<C> for i16where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for i32where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for i64where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for i128where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for u8
impl<C: ConfigCore> ZeroCopy<C> for u16where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for u32where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for u64where
C::IntEncoding: ZeroCopy<C>,
impl<C: ConfigCore> ZeroCopy<C> for u128where
C::IntEncoding: ZeroCopy<C>,
impl<const N: usize, C: ConfigCore, T> ZeroCopy<C> for [T; N]where
T: ZeroCopy<C>,
Implementors§
impl<C: ConfigCore> ZeroCopy<C> for FixIntwhere
C::ByteOrder: PlatformEndian,
Convenience to allow trait implementations to hook into the configured
IntEncoding and conditionally enable ZeroCopy.
For example, if a SchemaRead / SchemaWrite
implementation delegates its integer encoding to the configuration’s
IntEncoding, it can constrain its ZeroCopy bound by that encoding.