Struct wallet_core::Result
source · pub struct Result(Result<(), Error>);
Expand description
result returned by a call, this allows to check if an error occurred while executing the function.
if an error occurred it is then possible to collect more information about the kind of error as well as details from the underlying libraries that may be useful in case of bug reports or to figure out why the inputs were not valid and resulted in the function to return with error
Tuple Fields§
§0: Result<(), Error>
Implementations§
source§impl Result
impl Result
sourcepub fn error(&self) -> Option<&Error>
pub fn error(&self) -> Option<&Error>
if it is an error, this function will returns the the error object,
otherwise it will return None
sourcepub fn success() -> Self
pub fn success() -> Self
constructor to build a Result
that means success
example
let result = Result::success();
assert!(result.is_ok());
sourcepub fn with<E>(self, details: E) -> Selfwhere
E: Error + Send + Sync + 'static,
pub fn with<E>(self, details: E) -> Selfwhere E: Error + Send + Sync + 'static,
set some details to the Result
object if the Result
is of
error kind
If the Result
means success, then nothing is returned.
Example
fn example(pointer: *mut u8) -> Result {
if pointer.is_null() {
Error::invalid_input("pointer").into()
} else {
Result::success()
}
}
let mut input = 2;
let input: *mut u8 = &mut 2;
let result = example(input).with(NulPointer);
assert!(result.is_ok());
pub fn into_c_api(self) -> *mut Error
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Result
impl Send for Result
impl Sync for Result
impl Unpin for Result
impl !UnwindSafe for Result
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