pub struct ZffError { /* private fields */ }Expand description
The main error-type of this crate.
Implementations§
Source§impl ZffError
impl ZffError
Sourcepub fn new<S: Into<String>>(kind: ZffErrorKind, details: S) -> ZffError
pub fn new<S: Into<String>>(kind: ZffErrorKind, details: S) -> ZffError
Creates a new crate-related error.
§Example
use zff::{ZffError, ZffErrorKind, Result};
fn my_func() -> Result<()> {
let custom_error = ZffError::new(
ZffErrorKind::Custom, "My detailed custom error message");
Err(custom_error)
}
fn main() {
match my_func() {
Err(x) => println!("It work's! Your custom error message is: {}", x),
_ => ()
}
}Sourcepub fn new_custom<S: Into<String>>(details: S) -> ZffError
pub fn new_custom<S: Into<String>>(details: S) -> ZffError
Creates a new crate-related custom error.
§Example
use zff::{ZffError, Result};
fn my_func() -> Result<()> {
let custom_error = ZffError::new_custom("My detailed custom error message");
Err(custom_error)
}
fn main() {
match my_func() {
Err(x) => println!("It work's! Your custom error message is: {}", x),
_ => ()
}
}Sourcepub fn new_header_decode_error<S: Into<String>>(details: S) -> ZffError
pub fn new_header_decode_error<S: Into<String>>(details: S) -> ZffError
Creates a new crate-related header decode error.
§Example
use zff::{ZffError, Result};
fn my_func() -> Result<()> {
let decode_error = ZffError::new_header_decode_error("error while trying to decode CompressionHeader from given data");
Err(decode_error)
}
fn main() {
match my_func() {
Err(x) => println!("It work's! Your custom error message is: {}", x),
_ => ()
}
}Sourcepub fn get_kind(&self) -> &ZffErrorKind
pub fn get_kind(&self) -> &ZffErrorKind
Returns a reference to the kind.
§Example
use zff::{ZffError, ZffErrorKind, Result};
fn my_func() -> Result<()> {
let custom_error = ZffError::new_custom("My detailed custom error message");
Err(custom_error)
}
fn main() {
match my_func() {
Err(x) => {
assert!(matches!(x.get_kind(), &ZffErrorKind::Custom));
},
_ => ()
}
}Sourcepub fn unwrap_kind(self) -> ZffErrorKind
pub fn unwrap_kind(self) -> ZffErrorKind
returns the error kind and consumes self.
§Example
use zff::{ZffError, ZffErrorKind, Result};
fn my_func() -> Result<()> {
let custom_error = ZffError::new_custom("My detailed custom error message");
Err(custom_error)
}
fn main() {
match my_func() {
Err(x) => {
assert!(matches!(x.unwrap_kind(), ZffErrorKind::Custom));
},
_ => ()
}
}Trait Implementations§
Source§impl From<ComponentRange> for ZffError
impl From<ComponentRange> for ZffError
Source§fn from(e: ComponentRangeError) -> ZffError
fn from(e: ComponentRangeError) -> ZffError
Converts to this type from the input type.
Source§impl From<DecodeError> for ZffError
impl From<DecodeError> for ZffError
Source§fn from(e: Base64DecodingError) -> ZffError
fn from(e: Base64DecodingError) -> ZffError
Converts to this type from the input type.
Source§impl From<Error> for ZffError
impl From<Error> for ZffError
Source§fn from(e: PKCS5CryptoError) -> ZffError
fn from(e: PKCS5CryptoError) -> ZffError
Converts to this type from the input type.
Source§impl From<Error> for ZffError
impl From<Error> for ZffError
Source§fn from(e: EncryptionError) -> ZffError
fn from(e: EncryptionError) -> ZffError
Converts to this type from the input type.
Source§impl From<Error> for ZffError
impl From<Error> for ZffError
Source§fn from(e: Ed25519Error) -> ZffError
fn from(e: Ed25519Error) -> ZffError
Converts to this type from the input type.
Source§impl From<FromUtf8Error> for ZffError
impl From<FromUtf8Error> for ZffError
Source§fn from(e: FromUtf8Error) -> ZffError
fn from(e: FromUtf8Error) -> ZffError
Converts to this type from the input type.
Source§impl From<InvalidParams> for ZffError
impl From<InvalidParams> for ZffError
Source§fn from(e: ScryptErrorInvalidParams) -> ZffError
fn from(e: ScryptErrorInvalidParams) -> ZffError
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ZffError
impl !RefUnwindSafe for ZffError
impl Send for ZffError
impl Sync for ZffError
impl Unpin for ZffError
impl !UnwindSafe for ZffError
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more