#![no_std]
use zerocopy::FromBytes;
use zerocopy::Ref;
use zerocopy::Unalign;
pub trait FromBytesExt: FromBytes {
fn read_from_prefix_split(bytes: &[u8]) -> Option<(Self, &[u8])>
where
Self: Sized,
{
Ref::<_, Unalign<Self>>::new_unaligned_from_prefix(bytes)
.map(|(r, s)| (r.read().into_inner(), s))
}
fn read_from_suffix_split(bytes: &[u8]) -> Option<(&[u8], Self)>
where
Self: Sized,
{
Ref::<_, Unalign<Self>>::new_unaligned_from_suffix(bytes)
.map(|(s, r)| (s, r.read().into_inner()))
}
}
impl<T: FromBytes> FromBytesExt for T {}