pub enum ValidateError {
OutOfBounds {
addr: usize,
need: usize,
buf_len: usize,
},
Misaligned {
addr: usize,
align: usize,
},
NullNear {
addr: usize,
},
InvalidListHeader {
addr: usize,
},
ListLenMismatch {
addr: usize,
expected: u32,
actual: u32,
},
InvalidDiscriminant {
addr: usize,
value: u8,
max: u8,
},
InvalidBool {
addr: usize,
value: u8,
},
Uninhabited,
}Expand description
Error returned by Flat::validate and Region::from_bytes.
Variants§
OutOfBounds
Buffer is too small to hold the type at the given address.
Fields
Misaligned
Address is not correctly aligned for the type.
NullNear
A Near<T> offset is zero (null pointer).
InvalidListHeader
NearList header has inconsistent head/len (e.g. non-zero head with zero len).
ListLenMismatch
Segment lengths don’t sum to the total NearList length.
Fields
InvalidDiscriminant
Enum discriminant is not a valid variant.
Fields
InvalidBool
A bool value is not 0 or 1.
Uninhabited
An uninhabited type (Infallible) can never be valid.
Implementations§
Source§impl ValidateError
impl ValidateError
Sourcepub fn check_bounds<T>(addr: usize, buf: &[u8]) -> Result<(), Self>
pub fn check_bounds<T>(addr: usize, buf: &[u8]) -> Result<(), Self>
Check that buf has at least size_of::<T>() bytes starting at addr.
§Errors
Returns OutOfBounds if the buffer is too small.
Sourcepub const fn check_align<T>(addr: usize) -> Result<(), Self>
pub const fn check_align<T>(addr: usize) -> Result<(), Self>
Trait Implementations§
Source§impl Clone for ValidateError
impl Clone for ValidateError
Source§fn clone(&self) -> ValidateError
fn clone(&self) -> ValidateError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidateError
impl Debug for ValidateError
Source§impl Display for ValidateError
impl Display for ValidateError
Source§impl Error for ValidateError
impl Error for ValidateError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl PartialEq for ValidateError
impl PartialEq for ValidateError
impl Eq for ValidateError
impl StructuralPartialEq for ValidateError
Auto Trait Implementations§
impl Freeze for ValidateError
impl RefUnwindSafe for ValidateError
impl Send for ValidateError
impl Sync for ValidateError
impl Unpin for ValidateError
impl UnsafeUnpin for ValidateError
impl UnwindSafe for ValidateError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more