/// 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;
