Crate as_with_bytes [] [src]

Using these traits, values can be serialized as bytes without any copying of data whatsoever.

The generalization that is used here only works for data which contains no pointers to other data. As such, the traits are only implemented for types which implement Copy and for slices whose contents implement Copy.

This crate makes no guarantees about portability across systems; it simply encodes the raw bytes of values.

It's all the same block of memory

use as_with_bytes::{AsBytes, WithBytes};
use std::ptr;
let arr = [10, -11];
// They reference the same memory address
assert!(ptr::eq(unsafe { <[i32; 2]>::with_bytes(arr.as_bytes()) }, &arr));



A trait used for converting into bytes.


A trait for converting from bytes while checking that the byte slice is long enough.


A trait used for converting from bytes.