SysResult

Struct SysResult 

Source
pub struct SysResult(/* private fields */);
Expand description

Represents the results of a SafaOS syscall, either an ErrorStatus or an Ok usize value smaller than or equal to isize::MAX.

Implementations§

Source§

impl SysResult

Source

pub const fn err(err: ErrorStatus) -> Self

Converts an err into a SysResult.

Source

pub const fn into_result(self) -> Result<usize, ErrorStatus>

Turns a SysResult into result.

Source

pub const fn try_from_result( result: Result<usize, ErrorStatus>, ) -> Result<Self, ()>

Attempts to convert a result into SysResult, returns an error if the value is Ok(x) and x is larger than isize::MAX

Source

pub const fn ok(value: usize) -> Self

Converts an Ok value [value] into Self, it is expected to not be larger than isize::MAX or it panicks.

Source

pub const fn try_ok(value: usize) -> Result<Self, ()>

Tries to convert an Ok value [value] into SysResult, return an error if the value is larger than isize::MAX.

Source

pub const fn as_isize(&self) -> isize

Converts a SysResult into an isize, negative value is for an error, use Self::into_result instead.

Source

pub const fn from_isize(isize: isize) -> Self

Converts an isize into SysResult

§Safety

Perefectly safe as this type doesn’t guarantee the contained error value (negative value) is valid.

Trait Implementations§

Source§

impl Clone for SysResult

Source§

fn clone(&self) -> SysResult

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SysResult

Source§

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

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

impl From<ErrorStatus> for SysResult

Source§

fn from(value: ErrorStatus) -> Self

Converts to this type from the input type.
Source§

impl From<Result<usize, ErrorStatus>> for SysResult

Source§

fn from(value: Result<usize, ErrorStatus>) -> Self

Panicks if the results is an Ok value larger than isize::MAX

Source§

impl From<SysResult> for Result<usize, ErrorStatus>

Source§

fn from(value: SysResult) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for SysResult

Source§

fn from(value: isize) -> Self

Converts to this type from the input type.
Source§

impl Into<isize> for SysResult

Source§

fn into(self) -> isize

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for SysResult

Source§

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

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

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 Copy for SysResult

Source§

impl Eq for SysResult

Source§

impl StructuralPartialEq for SysResult

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.