pub struct Error<T = ()> { /* private fields */ }
Expand description
An error with a kind and a msg.
An Error
contains a ErrorKind
which gives context on the error cause,
as well as an Option<T>
which may be used to prevent the loss of data
in case of a failed send
function call. When no T
is specified, it
defaults to ()
.
§Usage example
use libzmq::{prelude::*, *, ErrorKind::*};
// This client has no peer and is therefore in mute state.
let client = Client::new()?;
// This means that the following call would block.
if let Err(mut err) = client.try_send("msg") {
match err.kind() {
// This covers all the possible error scenarios for this socket type.
// Normally we would process each error differently.
WouldBlock | InvalidCtx | Interrupted => {
// Here we get back the message we tried to send.
let msg = err.take().unwrap();
assert_eq!("msg", msg.to_str()?);
}
// Since `ErrorKind` is non-exhaustive, need an
// extra wildcard arm to account for potential future variants.
_ => panic!("unhandled error : {}", err),
}
}
Implementations§
Source§impl<T> Error<T>
impl<T> Error<T>
Trait Implementations§
Source§impl<T> Error for Error<T>
impl<T> Error for Error<T>
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<T> From<AddrParseError> for Error<T>
impl<T> From<AddrParseError> for Error<T>
Source§fn from(error: AddrParseError) -> Self
fn from(error: AddrParseError) -> Self
Converts to this type from the input type.
Source§impl<T> From<GroupParseError> for Error<T>
impl<T> From<GroupParseError> for Error<T>
Source§fn from(_error: GroupParseError) -> Self
fn from(_error: GroupParseError) -> Self
Converts to this type from the input type.
Source§impl<T> From<Infallible> for Error<T>
impl<T> From<Infallible> for Error<T>
Source§fn from(_error: Infallible) -> Self
fn from(_error: Infallible) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for Error<T>where
T: Freeze,
impl<T> RefUnwindSafe for Error<T>where
T: RefUnwindSafe,
impl<T> Send for Error<T>where
T: Send,
impl<T> Sync for Error<T>where
T: Sync,
impl<T> Unpin for Error<T>where
T: Unpin,
impl<T> UnwindSafe for Error<T>where
T: UnwindSafe,
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