warp_contracts_core::handler_result

Enum WriteResult

Source
pub enum WriteResult<State, Error> {
    Success(State),
    ContractError(Error),
    RuntimeError(String),
}
Expand description

Return type for ‘write’ contract method

User is responsible for providing State and Error types. To use them with #[warp_contract(write)] macro State have to implement:

  • Clone - to allow safe passing of a clone of state to contract method and disallow partial state changes in case an error is returned
  • Serialize, Deserialize - to pass it both ways between js and rust and Error have to implement Serialize.

Both types have to implement Debug to allow generic error message creation.

Variants§

§

Success(State)

returned on success - State contains the updated contract state

§

ContractError(Error)

returned when a ‘business’ error occurred, The user-defined Error parameter is returned to the caller.

§

RuntimeError(String)

returned when an unexpected error occurred, The String parameter is for debugging purposes

Trait Implementations§

Source§

impl<State: Debug, Error: Debug> Debug for WriteResult<State, Error>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<State, Error> Freeze for WriteResult<State, Error>
where State: Freeze, Error: Freeze,

§

impl<State, Error> RefUnwindSafe for WriteResult<State, Error>
where State: RefUnwindSafe, Error: RefUnwindSafe,

§

impl<State, Error> Send for WriteResult<State, Error>
where State: Send, Error: Send,

§

impl<State, Error> Sync for WriteResult<State, Error>
where State: Sync, Error: Sync,

§

impl<State, Error> Unpin for WriteResult<State, Error>
where State: Unpin, Error: Unpin,

§

impl<State, Error> UnwindSafe for WriteResult<State, Error>
where State: UnwindSafe, Error: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.