Enum dharitri_wasm::types::SCResult
source · pub enum SCResult<T, E = StaticSCError> {
Ok(T),
Err(E),
}Expand description
Default way to optionally return an error from a smart contract endpoint.
Variants§
Implementations§
source§impl<T, E> SCResult<T, E>
impl<T, E> SCResult<T, E>
pub fn is_ok(&self) -> bool
pub fn is_err(&self) -> bool
pub fn ok(self) -> Option<T>
pub fn err(self) -> Option<E>
sourcepub fn unwrap_or_signal_error<FA: EndpointFinishApi>(self, api: FA) -> Twhere
E: SCError,
pub fn unwrap_or_signal_error<FA: EndpointFinishApi>(self, api: FA) -> Twhere
E: SCError,
Returns the contained Ok value or signals the error and exits.
sourcepub fn from_result<FromErr>(r: Result<T, FromErr>) -> Selfwhere
FromErr: Into<E>,
pub fn from_result<FromErr>(r: Result<T, FromErr>) -> Selfwhere
FromErr: Into<E>,
Used to convert from a regular Rust result.
Any error type is accepted as long as it can be converted to a SCError
(Vec<u8>, &[u8], BoxedBytes, String, &str are covered).
Trait Implementations§
source§impl<T, E> EndpointResult for SCResult<T, E>where
T: EndpointResult,
E: SCError,
impl<T, E> EndpointResult for SCResult<T, E>where
T: EndpointResult,
E: SCError,
source§impl<T, FromErr> FromResidual<Result<Infallible, FromErr>> for SCResult<T>where
FromErr: Into<StaticSCError>,
impl<T, FromErr> FromResidual<Result<Infallible, FromErr>> for SCResult<T>where
FromErr: Into<StaticSCError>,
source§fn from_residual(residual: Result<Infallible, FromErr>) -> Self
fn from_residual(residual: Result<Infallible, FromErr>) -> Self
🔬This is a nightly-only experimental API. (
try_trait_v2)Constructs the type from a compatible
Residual type. Read moresource§impl<T, E> FromResidual for SCResult<T, E>
impl<T, E> FromResidual for SCResult<T, E>
source§fn from_residual(r: E) -> Self
fn from_residual(r: E) -> Self
🔬This is a nightly-only experimental API. (
try_trait_v2)Constructs the type from a compatible
Residual type. Read moresource§impl<T: PartialEq, E: PartialEq> PartialEq for SCResult<T, E>
impl<T: PartialEq, E: PartialEq> PartialEq for SCResult<T, E>
source§impl<T, E> Try for SCResult<T, E>
impl<T, E> Try for SCResult<T, E>
Implementing the Try trait overloads the ? operator.
Documentation on the new version of the trait:
https://github.com/scottmcm/rfcs/blob/do-or-do-not/text/0000-try-trait-v2.md#the-try-trait
§type Output = T
type Output = T
🔬This is a nightly-only experimental API. (
try_trait_v2)The type of the value produced by
? when not short-circuiting.§type Residual = E
type Residual = E
🔬This is a nightly-only experimental API. (
try_trait_v2)The type of the value passed to
FromResidual::from_residual
as part of ? when short-circuiting. Read moresource§fn branch(self) -> ControlFlow<Self::Residual, T>
fn branch(self) -> ControlFlow<Self::Residual, T>
🔬This is a nightly-only experimental API. (
try_trait_v2)Used in
? to decide whether the operator should produce a value
(because this returned ControlFlow::Continue)
or propagate a value back to the caller
(because this returned ControlFlow::Break). Read moresource§fn from_output(v: T) -> Self
fn from_output(v: T) -> Self
🔬This is a nightly-only experimental API. (
try_trait_v2)Constructs the type from its
Output type. Read moresource§impl<T: TypeAbi, E> TypeAbi for SCResult<T, E>
impl<T: TypeAbi, E> TypeAbi for SCResult<T, E>
fn type_name() -> String
source§fn provide_type_descriptions<TDC: TypeDescriptionContainer>(
accumulator: &mut TDC
)
fn provide_type_descriptions<TDC: TypeDescriptionContainer>( accumulator: &mut TDC )
A type can provide more than its own description.
For instance, a struct can also provide the descriptions of the type of its fields.
TypeAbi doesn’t care for the exact accumulator type,
which is abstracted by the TypeDescriptionContainer trait.
impl<T: Eq, E: Eq> Eq for SCResult<T, E>
impl<T, E> StructuralPartialEq for SCResult<T, E>
Auto Trait Implementations§
impl<T, E> RefUnwindSafe for SCResult<T, E>where
E: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, E> Send for SCResult<T, E>
impl<T, E> Sync for SCResult<T, E>
impl<T, E> Unpin for SCResult<T, E>
impl<T, E> UnwindSafe for SCResult<T, E>where
E: UnwindSafe,
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