Trait bytecheck::CheckBytes
source · pub unsafe trait CheckBytes<C: Fallible + ?Sized> {
// Required method
unsafe fn check_bytes(
value: *const Self,
context: &mut C
) -> Result<(), C::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.
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§
sourceunsafe fn check_bytes(
value: *const Self,
context: &mut C
) -> Result<(), C::Error>
unsafe fn check_bytes( value: *const Self, context: &mut C ) -> Result<(), C::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 initialized bytes to represent the type.
Object Safety§
This trait is not object safe.