Struct concordium_std::ParseError
source · [−]pub struct ParseError {}
Expand description
Zero-sized type to represent an error when reading bytes and deserializing.
When using custom error types in your smart contract, it is convenient to
implement the trait From<ParseError>
for you custom error type, to allow
using the ?
operator when deserializing bytes, such as the contract state
or parameters.
ⓘ
enum MyCustomReceiveError {
Parsing
}
impl From<ParseError> for MyCustomReceiveError {
fn from(_: ParseError) -> Self { MyCustomReceiveError::Parsing }
}
#[receive(contract = "mycontract", name="some_receive_name", mutable)]
fn contract_receive<S: HasStateApi>(
ctx: &impl HasReceiveContext,
host: &mut impl HasHost<State, StateApiType = S>,
) -> Result<A, MyCustomReceiveError> {
// ...
let msg: MyParameterType = ctx.parameter_cursor().get()?;
// ...
}
Trait Implementations
sourceimpl Debug for ParseError
impl Debug for ParseError
sourceimpl Default for ParseError
impl Default for ParseError
sourcefn default() -> ParseError
fn default() -> ParseError
Returns the “default value” for a type. Read more
sourceimpl Display for ParseError
impl Display for ParseError
sourceimpl Error for ParseError
impl Error for ParseError
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
sourceimpl From<ParseError> for Reject
impl From<ParseError> for Reject
Mapped to i32::MIN + 2.
sourcefn from(_: ParseError) -> Self
fn from(_: ParseError) -> Self
Converts to this type from the input type.
sourceimpl From<TestStateError> for ParseError
impl From<TestStateError> for ParseError
sourcefn from(_: TestStateError) -> Self
fn from(_: TestStateError) -> Self
Converts to this type from the input type.
sourceimpl From<TryFromIntError> for ParseError
impl From<TryFromIntError> for ParseError
sourcefn from(TryFromIntError) -> ParseError
fn from(TryFromIntError) -> ParseError
Converts to this type from the input type.
sourceimpl PartialEq<ParseError> for ParseError
impl PartialEq<ParseError> for ParseError
sourcefn eq(&self, other: &ParseError) -> bool
fn eq(&self, other: &ParseError) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl Eq for ParseError
impl StructuralEq for ParseError
impl StructuralPartialEq for ParseError
Auto Trait Implementations
impl RefUnwindSafe for ParseError
impl Send for ParseError
impl Sync for ParseError
impl Unpin for ParseError
impl UnwindSafe for ParseError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more