#[non_exhaustive]pub enum TryPeekAtError {
OutOfBounds(OutOfBounds),
InsufficientData(InsufficientDataAt),
}Expand description
An error that occurs when trying to peek at a specific offset in the buffer.
This error is returned when the offset is out of bounds or when there is insufficient data to peek the requested data.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
OutOfBounds(OutOfBounds)
An error that occurs when trying to peek at an offset that is out of bounds for the buffer.
InsufficientData(InsufficientDataAt)
An error that occurs when there is not enough data in the buffer to peek the requested data.
Implementations§
Source§impl TryPeekAtError
impl TryPeekAtError
Sourcepub const fn out_of_bounds(offset: usize, length: usize) -> Self
pub const fn out_of_bounds(offset: usize, length: usize) -> Self
Creates a new TryPeekAtError::OutOfBounds error.
Sourcepub const fn insufficient_data(available: usize, offset: usize) -> Self
pub const fn insufficient_data(available: usize, offset: usize) -> Self
Creates a new TryPeekAtError::InsufficientData error.
§Panics
- In debug builds, panics if
requested <= available(would not be an error). - The
requestedvalue must be a non-zero.
Sourcepub const fn insufficient_data_with_requested(
available: usize,
offset: usize,
requested: NonZeroUsize,
) -> Self
pub const fn insufficient_data_with_requested( available: usize, offset: usize, requested: NonZeroUsize, ) -> Self
Creates a new TryPeekAtError::InsufficientData error.
§Panics
- In debug builds, panics if
requested <= available(would not be an error). - The
requestedvalue must be a non-zero.
Trait Implementations§
Source§impl Clone for TryPeekAtError
impl Clone for TryPeekAtError
Source§fn clone(&self) -> TryPeekAtError
fn clone(&self) -> TryPeekAtError
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 TryPeekAtError
impl Debug for TryPeekAtError
Source§impl Display for TryPeekAtError
impl Display for TryPeekAtError
Source§impl Error for TryPeekAtError
impl Error for TryPeekAtError
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 From<InsufficientDataAt> for TryPeekAtError
impl From<InsufficientDataAt> for TryPeekAtError
Source§fn from(source: InsufficientDataAt) -> Self
fn from(source: InsufficientDataAt) -> Self
Converts to this type from the input type.
Source§impl From<OutOfBounds> for TryPeekAtError
impl From<OutOfBounds> for TryPeekAtError
Source§fn from(source: OutOfBounds) -> Self
fn from(source: OutOfBounds) -> Self
Converts to this type from the input type.
Source§impl From<TryPeekAtError> for Error
impl From<TryPeekAtError> for Error
Source§fn from(e: TryPeekAtError) -> Self
fn from(e: TryPeekAtError) -> Self
Converts to this type from the input type.
Source§impl PartialEq for TryPeekAtError
impl PartialEq for TryPeekAtError
impl Eq for TryPeekAtError
impl StructuralPartialEq for TryPeekAtError
Auto Trait Implementations§
impl Freeze for TryPeekAtError
impl RefUnwindSafe for TryPeekAtError
impl Send for TryPeekAtError
impl Sync for TryPeekAtError
impl Unpin for TryPeekAtError
impl UnwindSafe for TryPeekAtError
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