pub struct Error(/* private fields */);Expand description
API errors.
Errors are equivalent to u32 but only using the 24 least significant bits: 8 bits for the
error space and 16 bits for the error code. The 8 most significant bits are zero. It is possible
to encode a Result<u32, Error> into a i32 as long as the success value only uses the 31
least significant bits. Non-negative values encode success, while negative values encode the
error by taking its bitwise complement (thus setting the 8 most significant bits to 1).
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(space: impl SpaceParam, code: impl CodeParam) -> Self
pub fn new(space: impl SpaceParam, code: impl CodeParam) -> Self
Creates a new error.
Sourcepub fn pop(self) -> Self
pub fn pop(self) -> Self
Pops the error one level up.
User errors become internal errors. Internal errors become world errors.
Sourcepub fn decode(result: i32) -> Result<u32, Self>
pub fn decode(result: i32) -> Result<u32, Self>
Decodes a signed integer as a result (where errors are negative values).
§Panics
Panics if the signed integer is smaller than -16777216 (0xff000000).
Trait Implementations§
impl Copy for Error
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()