jam_types/simple_result_code.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
/// Type which represents a result from a host call/"machine context mutator".
pub type SimpleResult = u64;
#[repr(u64)]
pub enum SimpleResultCode {
Ok = 0,
Nothing = u64::MAX,
/// `WHAT` Host call index invalid.
HostCallInvalid = Self::Nothing as u64 - 1,
/// `OOB` The buffer itself is invalid (cannot be accessed).
OutOfBounds = Self::Nothing as u64 - 2,
/// `WHO` Target service is unknown.
IndexUnknown = Self::Nothing as u64 - 3,
/// `FULL` Too much storage is used by the service for its holdings.
StorageFull = Self::Nothing as u64 - 4,
/// `CORE` Bad core index given.
BadCore = Self::Nothing as u64 - 5,
/// `CASH` The caller has too little funding.
NoCash = Self::Nothing as u64 - 6,
/// `LOW` The gas limit provided is too low (lower than the amount of gas required for the
/// transfer).
GasLimitTooLow = Self::Nothing as u64 - 7,
/// `HIGH` The gas limit provided is too high (higher than the amount of gas remaining).
GasLimitTooHigh = Self::Nothing as u64 - 8,
/// `HUH` The item is already solicited or forgotten.
ActionInvalid = Self::Nothing as u64 - 9,
}
impl From<SimpleResultCode> for SimpleResult {
fn from(code: SimpleResultCode) -> Self {
code as Self
}
}
pub const LOWEST_ERROR: SimpleResult = SimpleResultCode::ActionInvalid as SimpleResult;
#[repr(u64)]
pub enum InvokeOutcomeCode {
/// `HALT` Completed normally.
Halt = 0,
/// `PANIC` Completed with a panic.
Panic = 1,
/// `FAULT` Completed with a page fault.
PageFault = 2,
/// `HOST` Completed with a host-call fault.
HostCallFault = 3,
/// `OOG` Completed by running out of gas.
OutOfGas = 4,
}
impl From<InvokeOutcomeCode> for u64 {
fn from(code: InvokeOutcomeCode) -> Self {
code as Self
}
}