win_crypto_ng::helpers

Trait AsBytes

Source
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 T
where T: Pod,

Source§

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