Struct spinoso_env::InvalidError
source · pub struct InvalidError(_);
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)>
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<InvalidError> for InvalidError
impl PartialEq<InvalidError> for InvalidError
source§fn eq(&self, other: &InvalidError) -> bool
fn eq(&self, other: &InvalidError) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<InvalidError> for InvalidError
impl PartialOrd<InvalidError> for InvalidError
source§fn partial_cmp(&self, other: &InvalidError) -> Option<Ordering>
fn partial_cmp(&self, other: &InvalidError) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more