Struct abi_stable::std_types::RIoError [−][src]
#[repr(C)]pub struct RIoError { /* fields omitted */ }
Expand description
Ffi safe equivalent to std::io::Error
.
Example
Defining an extern function to write a slice into a writer twice.
use abi_stable::{
erased_types::interfaces::IoWriteInterface,
rtry, sabi_extern_fn,
std_types::{RIoError, ROk, RResult},
traits::IntoReprC,
DynTrait, RMut,
};
use std::io::Write;
#[sabi_extern_fn]
pub fn write_slice_twice(
mut write: DynTrait<RMut<'_, ()>, IoWriteInterface>,
slice: &[u8],
) -> RResult<(), RIoError> {
rtry!(write.write_all(slice).into_c());
rtry!(write.write_all(slice).into_c());
ROk(())
}
Implementations
Constructs an RIoError
from an error and a std::io::ErrorKind
.
Example
use abi_stable::std_types::RIoError;
use std::io::ErrorKind;
let err = RIoError::new(ErrorKind::Other, "".parse::<u64>().unwrap_err());
Constructs an RIoError
from a type convertible into a
Box<dyn std::error::Error + Send + Sync + 'static>
, and a std::io::ErrorKind
.
Example
use abi_stable::std_types::RIoError;
use std::io::ErrorKind;
let str_err = "Timeout receiving the response from server.";
let err = RIoError::new_(ErrorKind::TimedOut, str_err);
Constructs an RIoError
from a std::io::ErrorKind
.
Example
use abi_stable::std_types::RIoError;
use std::io::ErrorKind;
let err = RIoError::from_kind(ErrorKind::AlreadyExists);
Constructs an RIoError
from a
Box<dyn std::error::Error + Send + Sync + 'static>
and a std::io::ErrorKind
.
Example
use abi_stable::std_types::RIoError;
use std::io::ErrorKind;
let str_err = "Could not create file \"memes.txt\" because it already exists.";
let err = RIoError::with_box(ErrorKind::AlreadyExists, str_err.into());
Constructs an RIoError
from an RBoxError
and a std::io::ErrorKind
.
Example
use abi_stable::std_types::RIoError;
use std::io::ErrorKind;
type DynErr = Box<dyn std::error::Error + Send + Sync>;
let str_err: DynErr = "IP address `256.256.256.256` is already in use.".into();
let err = RIoError::with_rboxerror(ErrorKind::AddrInUse, str_err.into());
Retrieves the kind of io error.
Example
use abi_stable::std_types::{RIoError, RIoErrorKind};
use std::io::ErrorKind;
let err = RIoError::from_kind(ErrorKind::AlreadyExists);
assert_eq!(err.kind(), RIoErrorKind::AlreadyExists);
Gets the internal error,
returning None
if this was constructed with RIoError::from_kind
.
Example
use abi_stable::std_types::{RBoxError, RIoError, RIoErrorKind};
use std::io::ErrorKind;
{
let err = RIoError::from_kind(ErrorKind::AlreadyExists);
assert_eq!(err.get_ref().map(|_| ()), None);
}
{
let msg = "Cannot access directory at \"/home/Steve/memes/\".";
let err = RIoError::new_(ErrorKind::PermissionDenied, msg);
assert!(err.get_ref().is_some());
}
Gets the internal error,
returning None
if this was constructed with RIoError::from_kind
.
Example
use abi_stable::std_types::{RBoxError, RIoError, RIoErrorKind};
use std::io::ErrorKind;
{
let mut err = RIoError::from_kind(ErrorKind::AlreadyExists);
assert_eq!(err.get_mut().map(|_| ()), None);
}
{
let mut msg = "Cannot access directory at \"/home/Patrick/373.15K takes/\".";
let mut err = RIoError::new_(ErrorKind::PermissionDenied, msg);
assert!(err.get_mut().is_some());
}
Converts this into the internal error,
returning None
if this was constructed with RIoError::from_kind
.
Example
use abi_stable::std_types::RIoError;
use std::io::ErrorKind;
{
let err = RIoError::from_kind(ErrorKind::AlreadyExists);
assert_eq!(err.into_inner().map(|_| ()), None);
}
{
let mut msg = "Cannot access directory at \"/home/wo_boat/blog/\".";
let err = RIoError::new_(ErrorKind::PermissionDenied, msg);
assert!(err.into_inner().is_some());
}
Trait Implementations
Performs the conversion.
type StaticEquivalent = _static_RIoError
type IsNonZeroType = False
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
The layout of the type provided by implementors.
const
-equivalents of the associated types.
Auto Trait Implementations
impl RefUnwindSafe for RIoError
impl UnwindSafe for RIoError
Blanket Implementations
Mutably borrows from an owned value. Read more
type ForSelf = WithMetadata_<T, T>
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
Compares the address of self
with the address of other
. Read more
Emulates the pipeline operator, allowing method syntax in more places. Read more
The same as piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read more
The same as piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
. Read more
Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Performs a conversion with Into
.
using the turbofish .into_::<_>()
syntax. Read more
Performs a reference to reference conversion with AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more
Performs a mutable reference to mutable reference conversion with AsMut
,
using the turbofish .as_mut_::<_>()
syntax. Read more
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
type Type = T
type Type = T
This is always Self
.
Converts a value back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
Converts a value back to the original type.
Converts a reference back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
alloc
only.Converts an Arc back to the original type.
alloc
only.Converts an Rc back to the original type.