#[repr(C)]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
impl Retval
Sourcepub const fn from_usize(v: usize) -> Retval
pub const fn from_usize(v: usize) -> Retval
Create a new return-value from raw data
Sourcepub const fn is_success(self) -> bool
pub const fn is_success(self) -> bool
Check whether this is a success-return
Sourcepub unsafe fn error_unchecked(self) -> usize
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.
Sourcepub fn error(self) -> usize
pub fn error(self) -> usize
Return the error-code
If self
is not actually an error-return, this will panic.
Sourcepub unsafe fn unwrap_unchecked(self) -> usize
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.
Sourcepub fn unwrap(self) -> usize
pub fn unwrap(self) -> usize
Return the success value
If self
is not a success-return, this will panic.
Sourcepub fn to_result(self) -> Result<usize, usize>
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.