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>(self) -> Twhere
FA: EndpointFinishApi,
E: SCError,
pub fn unwrap_or_signal_error<FA>(self) -> Twhere
FA: EndpointFinishApi,
E: SCError,
Returns the contained Ok value or signals the error and exits.
Sourcepub fn from_result<FromErr>(r: Result<T, FromErr>) -> SCResult<T, E>where
FromErr: Into<E>,
pub fn from_result<FromErr>(r: Result<T, FromErr>) -> SCResult<T, E>where
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 as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::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, E> TypeAbi for SCResult<T, E>where
T: TypeAbi,
impl<T, E> TypeAbi for SCResult<T, E>where
T: TypeAbi,
type Unmanaged = SCResult<T, E>
fn type_name() -> String
fn type_name_rust() -> String
Source§fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
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, E> Eq for SCResult<T, E>
impl<T, E> StructuralPartialEq for SCResult<T, E>
impl<T, E> TypeAbiFrom<SCResult<T, E>> for SCResult<T, E>where
T: TypeAbi,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> InterpretableFrom<&T> for Twhere
T: Clone,
impl<T> InterpretableFrom<&T> for Twhere
T: Clone,
fn interpret_from(from: &T, _context: &InterpreterContext) -> T
Source§impl<T> InterpretableFrom<T> for T
impl<T> InterpretableFrom<T> for T
fn interpret_from(from: T, _context: &InterpreterContext) -> T
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