Trait bytecheck::CheckBytes

source ·
pub trait CheckBytes<C: ?Sized> {
    type Error: Error + 'static;

    // Required method
    unsafe fn check_bytes<'a>(
        value: *const Self,
        context: &mut C
    ) -> Result<&'a Self, Self::Error>;
}
Expand description

A type that can check whether a pointer points to a valid value.

CheckBytes can be derived with CheckBytes or implemented manually for custom behavior.

Required Associated Types§

source

type Error: Error + 'static

The error that may result from checking the type.

Required Methods§

source

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

Checks whether the given pointer points to a valid value within the given context.

Safety

The passed pointer must be aligned and point to enough bytes to represent the type.

Implementations on Foreign Types§

source§

impl<C: ?Sized> CheckBytes<C> for RangeFull

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T4, T3, T2, T1, T0)

§

type Error = Tuple5CheckError<<T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicI64

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T8: CheckBytes<C>, T7: CheckBytes<C>, T6: CheckBytes<C>, T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T8, T7, T6, T5, T4, T3, T2, T1, T0)

§

type Error = Tuple9CheckError<<T8 as CheckBytes<C>>::Error, <T7 as CheckBytes<C>>::Error, <T6 as CheckBytes<C>>::Error, <T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicI16

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: CheckBytes<C>, C: ?Sized> CheckBytes<C> for [T]

§

type Error = SliceCheckError<<T as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroI16

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicU32

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicI32

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: CheckBytes<C>, C: ?Sized> CheckBytes<C> for RangeToInclusive<T>

§

type Error = StructCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicU64

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: CheckBytes<C>, C: ?Sized, const N: usize> CheckBytes<C> for [T; N]

§

type Error = ArrayCheckError<<T as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for i16

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroU16

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T3, T2, T1, T0)

§

type Error = Tuple4CheckError<<T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for u8

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T7: CheckBytes<C>, T6: CheckBytes<C>, T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T7, T6, T5, T4, T3, T2, T1, T0)

§

type Error = Tuple8CheckError<<T7 as CheckBytes<C>>::Error, <T6 as CheckBytes<C>>::Error, <T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for char

§

type Error = CharCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for bool

§

type Error = BoolCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for f32

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T0,)

§

type Error = Tuple1CheckError<<T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for u128

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T6: CheckBytes<C>, T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T6, T5, T4, T3, T2, T1, T0)

§

type Error = Tuple7CheckError<<T6 as CheckBytes<C>>::Error, <T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroU64

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroI32

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroU8

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroI64

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicU16

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for u16

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for u64

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroI8

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T5, T4, T3, T2, T1, T0)

§

type Error = Tuple6CheckError<<T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: ?Sized, C: ?Sized> CheckBytes<C> for PhantomData<T>

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroU128

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T2, T1, T0)

§

type Error = Tuple3CheckError<<T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicI8

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T1, T0)

§

type Error = Tuple2CheckError<<T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T11: CheckBytes<C>, T10: CheckBytes<C>, T9: CheckBytes<C>, T8: CheckBytes<C>, T7: CheckBytes<C>, T6: CheckBytes<C>, T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)

§

type Error = Tuple12CheckError<<T11 as CheckBytes<C>>::Error, <T10 as CheckBytes<C>>::Error, <T9 as CheckBytes<C>>::Error, <T8 as CheckBytes<C>>::Error, <T7 as CheckBytes<C>>::Error, <T6 as CheckBytes<C>>::Error, <T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: CheckBytes<C>, C: ?Sized> CheckBytes<C> for RangeTo<T>

§

type Error = StructCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for f64

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicU8

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: CheckBytes<C>, C: ?Sized> CheckBytes<C> for Range<T>

§

type Error = StructCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroU32

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for i32

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T: CheckBytes<C>, C: ?Sized> CheckBytes<C> for RangeFrom<T>

§

type Error = StructCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for PhantomPinned

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T9: CheckBytes<C>, T8: CheckBytes<C>, T7: CheckBytes<C>, T6: CheckBytes<C>, T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)

§

type Error = Tuple10CheckError<<T9 as CheckBytes<C>>::Error, <T8 as CheckBytes<C>>::Error, <T7 as CheckBytes<C>>::Error, <T6 as CheckBytes<C>>::Error, <T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for u32

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized, T: CheckBytes<C> + ?Sized> CheckBytes<C> for ManuallyDrop<T>

§

type Error = <T as CheckBytes<C>>::Error

source§

unsafe fn check_bytes<'a>( value: *const Self, c: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for str

§

type Error = StrCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for ()

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for CStr

§

type Error = CStrCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for AtomicBool

§

type Error = BoolCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for i128

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<T10: CheckBytes<C>, T9: CheckBytes<C>, T8: CheckBytes<C>, T7: CheckBytes<C>, T6: CheckBytes<C>, T5: CheckBytes<C>, T4: CheckBytes<C>, T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)

§

type Error = Tuple11CheckError<<T10 as CheckBytes<C>>::Error, <T9 as CheckBytes<C>>::Error, <T8 as CheckBytes<C>>::Error, <T7 as CheckBytes<C>>::Error, <T6 as CheckBytes<C>>::Error, <T5 as CheckBytes<C>>::Error, <T4 as CheckBytes<C>>::Error, <T3 as CheckBytes<C>>::Error, <T2 as CheckBytes<C>>::Error, <T1 as CheckBytes<C>>::Error, <T0 as CheckBytes<C>>::Error>

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for NonZeroI128

§

type Error = NonZeroCheckError

source§

unsafe fn check_bytes<'a>( value: *const Self, context: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for i64

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

source§

impl<C: ?Sized> CheckBytes<C> for i8

§

type Error = Infallible

source§

unsafe fn check_bytes<'a>( value: *const Self, _: &mut C ) -> Result<&'a Self, Self::Error>

Implementors§