Skip to main content

ZeroCopy

Trait ZeroCopy 

Source
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§

Source

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.

Source

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§

Source§

impl<C: ConfigCore> ZeroCopy<C> for f32

Source§

impl<C: ConfigCore> ZeroCopy<C> for f64

Source§

impl<C: ConfigCore> ZeroCopy<C> for i8

Source§

impl<C: ConfigCore> ZeroCopy<C> for i16
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for i32
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for i64
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for i128
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for u8

Source§

impl<C: ConfigCore> ZeroCopy<C> for u16
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for u32
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for u64
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<C: ConfigCore> ZeroCopy<C> for u128
where C::IntEncoding: ZeroCopy<C>,

Source§

impl<const N: usize, C: ConfigCore, T> ZeroCopy<C> for [T; N]
where T: ZeroCopy<C>,

Implementors§

Source§

impl<C: ConfigCore> ZeroCopy<C> for FixInt

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.

Source§

impl<T, C: ConfigCore> ZeroCopy<C> for Pod<T>
where T: Copy + 'static,