ssb-boxstream 0.2.2

Encrypted box-stream protocol for Secure Scuttlebutt
Documentation
1
2
3
4
5
6
7
8
9
10
use zerocopy::LayoutVerified;
pub use zerocopy::{AsBytes, FromBytes};

pub fn cast<T: FromBytes>(b: &[u8]) -> &T {
    LayoutVerified::<&[u8], T>::new(b).unwrap().into_ref()
}

pub fn cast_mut<T: AsBytes + FromBytes>(b: &mut [u8]) -> &mut T {
    LayoutVerified::<&mut [u8], T>::new(b).unwrap().into_mut()
}