1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
use super::{ArchivedBox, ArchivedString, ArchivedVec}; use crate::core_impl::ArchivedStringSlice; use bytecheck::CheckBytes; impl<T: CheckBytes<C>, C> CheckBytes<C> for ArchivedBox<T> { type Error = <T as CheckBytes<C>>::Error; unsafe fn check_bytes<'a>(bytes: *const u8, context: &mut C) -> Result<&'a Self, Self::Error> { T::check_bytes(bytes, context)?; Ok(&*bytes.cast()) } } impl<C> CheckBytes<C> for ArchivedString where ArchivedStringSlice: CheckBytes<C>, { type Error = <ArchivedStringSlice as CheckBytes<C>>::Error; unsafe fn check_bytes<'a>(bytes: *const u8, context: &mut C) -> Result<&'a Self, Self::Error> { ArchivedStringSlice::check_bytes(bytes, context)?; Ok(&*bytes.cast()) } } impl<T: CheckBytes<C>, C> CheckBytes<C> for ArchivedVec<T> { type Error = <T as CheckBytes<C>>::Error; unsafe fn check_bytes<'a>(bytes: *const u8, context: &mut C) -> Result<&'a Self, Self::Error> { T::check_bytes(bytes, context)?; Ok(&*bytes.cast()) } }