pub unsafe trait AsBytes {
    // Provided methods
    fn as_bytes(&self) -> &[u8]  { ... }
    fn into_bytes(self: Box<Self>) -> Box<[u8]> { ... }
}
Expand description

Marker trait for types that can be safely converted to bytes.

Safety

Implementee MUST be #[repr(C)] and:

  • not contain any pointer types that are dereferenced,
  • itself or any of its members MUST NOT implement a custom destructor,
  • be inhabited,
  • allow any bit pattern

Layout

Implementee also needs to be layout-compatible with u8.

Provided Methods§

source

fn as_bytes(&self) -> &[u8]

source

fn into_bytes(self: Box<Self>) -> Box<[u8]>

Implementors§

source§

impl<T> AsBytes for Twhere T: Pod,

source§

impl<T: BlobLayout> AsBytes for Blob<T>