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§
source§impl Debug for ParseError
impl Debug for ParseError
source§impl Default for ParseError
impl Default for ParseError
source§fn default() -> ParseError
fn default() -> ParseError
Returns the “default value” for a type. Read more
source§impl Display for ParseError
impl Display for ParseError
source§impl Error for ParseError
impl Error for ParseError
1.30.0 · source§fn 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 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl From<ParseError> for Reject
impl From<ParseError> for Reject
Mapped to i32::MIN + 2.
source§fn from(_: ParseError) -> Self
fn from(_: ParseError) -> Self
Converts to this type from the input type.
source§impl From<TestStateError> for ParseError
impl From<TestStateError> for ParseError
source§fn from(_: TestStateError) -> Self
fn from(_: TestStateError) -> Self
Converts to this type from the input type.
source§impl From<TryFromIntError> for ParseError
impl From<TryFromIntError> for ParseError
source§fn from(_: TryFromIntError) -> ParseError
fn from(_: TryFromIntError) -> ParseError
Converts to this type from the input type.
source§impl PartialEq<ParseError> for ParseError
impl PartialEq<ParseError> for ParseError
source§fn 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 ==
.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§
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