Struct ResultCode

Source
#[repr(C)]
pub struct ResultCode { /* private fields */ }
Expand description

Represents a (raw) result value used all over the OS

These are referred as Result on docs/official code, but we intentionally name it as ResultCode to distinguish it from the Result enum type

Results are often displayed/shown, for example, like 2168-0002, which corresponds to <2000 + module>-<description>

[Debug][fmt::Debug] formatting formats the results as a hex-value (0x4A8), while [Display][fmt::Display] formatting formats the result in the format described above (2168-0002)

Implementations§

Source§

impl ResultCode

Source

pub const fn new(value: u32) -> Self

Creates a ResultCode from a raw value

§Arguments
  • value: The raw value
Source

pub const fn new_err<T>(value: u32) -> Result<T>

Wrapper for creating a new [Result::Err] value with the following raw result

§Arguments
  • value: The raw value, note that it mustn’t be 0/success (that would be undefined behavior)
Source

pub const fn is_success(&self) -> bool

Returns whether the ResultCode is successful

A result value of 0 is a successful value, this essentially checks that

Source

pub const fn is_failure(&self) -> bool

Returns whether the ResultCode is not successful

This is the exact opposite of is_success

Source

pub const fn get_value(&self) -> u32

Gets the raw value of the ResultCode

Source

pub const fn get_module(&self) -> u32

Gets the module of the ResultCode

Source

pub const fn get_description(&self) -> u32

Gets the description of the ResultCode

Trait Implementations§

Source§

impl Clone for ResultCode

Source§

fn clone(&self) -> ResultCode

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResultCode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ResultCode

Source§

fn default() -> ResultCode

Returns the “default value” for a type. Read more
Source§

impl Display for ResultCode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<AllocError> for ResultCode

Source§

fn from(_value: AllocError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ResultCode

Source§

fn eq(&self, other: &ResultCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RequestCommandParameter<ResultCode> for ResultCode

Source§

impl RequestCommandParameter for ResultCode

Source§

fn before_request_write( _raw: &Self, walker: &mut DataWalker, ctx: &mut CommandContext, ) -> Result<()>

Source§

fn before_send_sync_request( raw: &Self, walker: &mut DataWalker, ctx: &mut CommandContext, ) -> Result<()>

Source§

impl ResponseCommandParameter<ResultCode> for ResultCode

Source§

fn after_response_read( walker: &mut DataWalker, ctx: &mut CommandContext, ) -> Result<Self>

Source§

impl ResponseCommandParameter for ResultCode

Source§

type CarryState = ()

Source§

fn before_response_write( _raw: &Self, ctx: &mut ServerContext<'_>, ) -> Result<Self::CarryState>

Source§

fn after_response_write( raw: Self, _carry_state: Self::CarryState, ctx: &mut ServerContext<'_>, ) -> Result<()>

Source§

impl Copy for ResultCode

Source§

impl Eq for ResultCode

Source§

impl StructuralPartialEq for ResultCode

Auto Trait Implementations§

§

impl Freeze for ResultCode

§

impl RefUnwindSafe for ResultCode

§

impl Send for ResultCode

§

impl Sync for ResultCode

§

impl Unpin for ResultCode

§

impl UnwindSafe for ResultCode

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.