pub struct InvalidError(/* private fields */);
Expand description
Error that indicates the underlying platform API returned an error.
This error is typically returned by the operating system and corresponds to
EINVAL
.
§Examples
let err = InvalidError::new();
assert_eq!(err.message(), b"Errno::EINVAL");
let err = InvalidError::with_message("Invalid argument - setenv()");
assert_eq!(err.message(), b"Invalid argument - setenv()");
Implementations§
Source§impl InvalidError
impl InvalidError
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct a new, default invalid error.
§Examples
const ERR: InvalidError = InvalidError::new();
assert_eq!(ERR.message(), b"Errno::EINVAL");
Sourcepub const fn with_message(message: &'static str) -> Self
pub const fn with_message(message: &'static str) -> Self
Construct a new, invalid error with a message.
§Examples
const ERR: InvalidError = InvalidError::with_message("Invalid argument - setenv()");
assert_eq!(ERR.message(), b"Invalid argument - setenv()");
Sourcepub fn message(&self) -> &[u8] ⓘ
pub fn message(&self) -> &[u8] ⓘ
Retrieve the exception message associated with this invalid error.
§Examples
let err = InvalidError::new();
assert_eq!(err.message(), b"Errno::EINVAL");
Sourcepub fn into_message(self) -> Cow<'static, [u8]>
pub fn into_message(self) -> Cow<'static, [u8]>
Consume this error and return the inner message.
This method allows taking ownership of this error’s message without an allocation.
§Examples
let err = InvalidError::new();
assert_eq!(err.into_message(), Cow::Borrowed(b"Errno::EINVAL"));
Trait Implementations§
Source§impl Clone for InvalidError
impl Clone for InvalidError
Source§fn clone(&self) -> InvalidError
fn clone(&self) -> InvalidError
Returns a copy 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 InvalidError
impl Debug for InvalidError
Source§impl Display for InvalidError
impl Display for InvalidError
Source§impl Error for InvalidError
impl Error for InvalidError
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 From<&'static [u8]> for InvalidError
impl From<&'static [u8]> for InvalidError
Source§impl From<&'static str> for InvalidError
impl From<&'static str> for InvalidError
Source§impl From<InvalidError> for Error
impl From<InvalidError> for Error
Source§fn from(err: InvalidError) -> Self
fn from(err: InvalidError) -> Self
Converts to this type from the input type.
Source§impl Hash for InvalidError
impl Hash for InvalidError
Source§impl Ord for InvalidError
impl Ord for InvalidError
Source§fn cmp(&self, other: &InvalidError) -> Ordering
fn cmp(&self, other: &InvalidError) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for InvalidError
impl PartialEq for InvalidError
Source§impl PartialOrd for InvalidError
impl PartialOrd for InvalidError
impl Eq for InvalidError
impl StructuralPartialEq for InvalidError
Auto Trait Implementations§
impl Freeze for InvalidError
impl RefUnwindSafe for InvalidError
impl Send for InvalidError
impl Sync for InvalidError
impl Unpin for InvalidError
impl UnwindSafe for InvalidError
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