bytecheck

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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 char

Source§

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 f32

Source§

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 f64

Source§

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

Source§

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 i16

Source§

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 i32

Source§

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 i64

Source§

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 i128

Source§

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 str

Source§

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 u8

Source§

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

Source§

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 u32

Source§

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

Source§

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 u128

Source§

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 ()

Source§

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

Source§

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 PhantomPinned

Source§

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 RangeFull

Source§

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 AtomicBool

Source§

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 AtomicI8

Source§

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 AtomicI16

Source§

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

Source§

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 AtomicI64

Source§

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

Source§

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 AtomicU16

Source§

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 AtomicU32

Source§

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 AtomicU64

Source§

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

Source§

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 NonZeroI16

Source§

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

Source§

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

Source§

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 NonZeroI128

Source§

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

Source§

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 NonZeroU16

Source§

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 NonZeroU32

Source§

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 NonZeroU64

Source§

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 NonZeroU128

Source§

type Error = NonZeroCheckError

Source§

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

Source§

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

Source§

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<T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T0,)

Source§

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<T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T1, T0)

Source§

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<T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T2, T1, T0)

Source§

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<T3: CheckBytes<C>, T2: CheckBytes<C>, T1: CheckBytes<C>, T0: CheckBytes<C>, C: ?Sized> CheckBytes<C> for (T3, T2, T1, T0)

Source§

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<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)

Source§

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<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)

Source§

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<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)

Source§

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<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)

Source§

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<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)

Source§

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<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)

Source§

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<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)

Source§

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<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)

Source§

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 [T]

Source§

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<T: CheckBytes<C>, C: ?Sized> CheckBytes<C> for Range<T>

Source§

type Error = StructCheckError

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 RangeFrom<T>

Source§

type Error = StructCheckError

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>

Source§

type Error = StructCheckError

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 RangeToInclusive<T>

Source§

type Error = StructCheckError

Source§

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

Source§

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

Source§

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<T: ?Sized, C: ?Sized> CheckBytes<C> for PhantomData<T>

Source§

type Error = Infallible

Source§

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

Implementors§