Trait bytecheck::CheckBytes

source ·
pub unsafe trait CheckBytes<C: ?Sized, E> {
    // Required method
    unsafe fn check_bytes(value: *const Self, context: &mut C) -> Result<(), E>;
}
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.

Safety

check_bytes must only return Ok if value points to a valid instance of Self. Because value must always be properly aligned for Self and point to enough bytes to represent the type, this implies that value may be dereferenced safely.

Required Methods§

source

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

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 initialized bytes to represent the type.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for bool

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for char

source§

unsafe fn check_bytes(ptr: *const Self, _: &mut C) -> Result<(), E>

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for str

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for CStr

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroI8

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroI16

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroI32

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroI64

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroI128

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroU8

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroU16

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroU32

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroU64

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for NonZeroU128

source§

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

source§

impl<C: ?Sized, E: Error> CheckBytes<C, E> for AtomicBool

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§