pub enum SCResult<T, E = StaticSCError> {
Ok(T),
Err(E),
}
👎Deprecated since 0.48.0: Use in-place error handling instead, such as
require!
or sc_panic!
Expand description
Default way to optionally return an error from a smart contract endpoint.
Variants§
Ok(T)
👎Deprecated since 0.48.0: Use in-place error handling instead, such as
require!
or sc_panic!
Err(E)
👎Deprecated since 0.48.0: Use in-place error handling instead, such as
require!
or sc_panic!
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) -> Twhere
E: SCError,
pub fn unwrap_or_signal_error<FA: EndpointFinishApi>(self) -> 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> TopEncodeMulti for SCResult<T, E>where
T: TopEncodeMulti,
E: TopEncodeMulti,
impl<T, E> TopEncodeMulti for SCResult<T, E>where
T: TopEncodeMulti,
E: TopEncodeMulti,
Source§fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), H::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), H::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
Version of
top_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
Attempt to serialize the value to ouput.
Source§impl<T: TypeAbi, E> TypeAbi for SCResult<T, E>
impl<T: TypeAbi, E> TypeAbi for SCResult<T, E>
type Unmanaged = SCResult<T, E>
fn type_name() -> TypeName
fn type_name_rust() -> TypeName
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 name.
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.
fn type_names() -> TypeNames
impl<T: Eq, E: Eq> Eq for SCResult<T, E>
impl<T, E> StructuralPartialEq for SCResult<T, E>
impl<T: TypeAbi, E> TypeAbiFrom<SCResult<T, E>> for SCResult<T, E>
Auto Trait Implementations§
impl<T, E> Freeze for SCResult<T, E>
impl<T, E> RefUnwindSafe for SCResult<T, E>where
T: RefUnwindSafe,
E: 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
T: UnwindSafe,
E: 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