ink_env::reflect

Trait ConstructorOutput

pub trait ConstructorOutput<C>: Sealed {
    type Error;

    const IS_RESULT: bool = false;

    // Required method
    fn as_result(&self) -> Result<&C, &Self::Error>;
}
Expand description

Guards against using invalid contract initializer types.

§Note

Currently the only allowed types are () and Result<(), E> where E is some unspecified error type. If the contract initializer returns Result::Err the utility method that is used to initialize an ink! smart contract will revert the state of the contract instantiation.

Provided Associated Constants§

const IS_RESULT: bool = false

Is true if Self is Result<C, E>.

Required Associated Types§

type Error

The error type of the constructor return type.

§Note

For infallible constructors this is () whereas for fallible constructors this is the actual return error type. Since we only ever return a value in case of Result::Err the Result::Ok value type does not matter.

Required Methods§

fn as_result(&self) -> Result<&C, &Self::Error>

Converts the return value into a Result instance.

§Note

For infallible constructor returns this always yields Ok.

Object Safety§

This trait is not object safe.

Implementors§

§

impl<C> ConstructorOutput<C> for ConstructorOutputValue<C>

§

type Error = &'static ()

§

impl<C, E> ConstructorOutput<C> for ConstructorOutputValue<Result<C, E>>

§

const IS_RESULT: bool = true

§

type Error = E