Struct concordium_std::ParseError[][src]

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::ParseParams }
}

#[receive(contract = "mycontract", name="some_receive_name")]
fn contract_receive<R: HasReceiveContext, L: HasLogger, A: HasActions>(
    ctx: &R,
    receive_amount: Amount,
    logger: &mut L,
    state: &mut State,
) -> Result<A, MyCustomReceiveError> {
    ...
    let msg: MyParameterType = ctx.parameter_cursor().get()?;
    ...
}

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.