Skip to main content

Retval

Struct Retval 

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

System Call Return Value

On linux platforms, system calls return native integers as result. A special range is used for errors. This type wraps this result type and provides accessors to its underlying values.

Implementations§

Source§

impl Retval

Source

pub const fn from_usize(v: usize) -> Retval

Create a new return-value from raw data

Source

pub const fn as_usize(self) -> usize

Return raw underlying data of a return-value

Source

pub const fn is_error(self) -> bool

Check whether this is an error-return

Source

pub const fn is_success(self) -> bool

Check whether this is a success-return

Source

pub unsafe fn error_unchecked(self) -> usize

Return the error-code unchecked

§Safety

This does not verify that self is actually an error-return. It assumes the caller verified it.

Source

pub fn error(self) -> usize

Return the error-code

If self is not actually an error-return, this will panic.

Source

pub unsafe fn unwrap_unchecked(self) -> usize

Return the success-value unchecked

§Safety

This does not verify that self is actually a success-return. It assumes the caller verified it.

Source

pub fn unwrap(self) -> usize

Return the success value

If self is not a success-return, this will panic.

Source

pub fn to_result(self) -> Result<usize, usize>

Convert into a Result

This converts the return value into a rust-native Result type. This maps the error-return to Err(code) and the success-return to Ok(usize). This allows using the rich convenience library of the Result type, rather than re-implementing them for this native type.

Trait Implementations§

Source§

impl Clone for Retval

Source§

fn clone(&self) -> Retval

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Retval

Source§

impl Debug for Retval

Source§

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

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

impl Eq for Retval

Source§

impl PartialEq for Retval

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Retval

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.