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
/// Type which represents a result from a host call/"machine context mutator".
pub type SimpleResult = u32;

#[repr(u32)]
pub enum SimpleResultCode {
	Ok = 0,
	Nothing = u32::MAX,
	/// `WHAT` Host call index invalid.
	HostCallInvalid = Self::Nothing as u32 - 1,
	/// `OOB` The buffer itself is invalid (cannot be accessed).
	OutOfBounds = Self::Nothing as u32 - 2,
	/// `WHO` Target service is unknown.
	IndexUnknown = Self::Nothing as u32 - 3,
	/// `FULL` Too much storage is used by the service for its holdings.
	StorageFull = Self::Nothing as u32 - 4,
	/// `CORE` Bad core index given.
	BadCore = Self::Nothing as u32 - 5,
	/// `CASH` The caller has too little funding.
	NoCash = Self::Nothing as u32 - 6,
	/// `LOW` The gas limit provided is too low (lower than the amount of gas required for the
	/// transfer).
	GasLimitTooLow = Self::Nothing as u32 - 7,
	/// `HIGH` The gas limit provided is too high (higher than the amount of gas remaining).
	GasLimitTooHigh = Self::Nothing as u32 - 8,
	/// `HUH` The item is already solicited or forgotten.
	ActionInvalid = Self::Nothing as u32 - 9,
}

impl From<SimpleResultCode> for SimpleResult {
	fn from(code: SimpleResultCode) -> Self {
		code as Self
	}
}

pub const LOWEST_ERROR: SimpleResult = SimpleResultCode::ActionInvalid as SimpleResult;