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

source

pub fn is_ok(&self) -> bool

returns true if the Result means success

source

pub fn is_err(&self) -> bool

returns true if the Result means error

source

pub fn error(&self) -> Option<&Error>

if it is an error, this function will returns the the error object, otherwise it will return None

source

pub fn success() -> Self

constructor to build a Result that means success

example

let result = Result::success();

assert!(result.is_ok());
source

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());
source

pub fn into_c_api(self) -> *mut Error

Trait Implementations§

source§

impl From<Error> for Result

source§

fn from(error: Error) -> Self

Converts to this type from the input type.
source§

impl From<Result<(), Error>> for Result

source§

fn from(result: Result<(), Error>) -> Self

Converts to this type from the input type.

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more