[−][src]Struct abi_stable::std_types::RIoError
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, std_types::{RIoError,RResult,ROk}, traits::IntoReprC, DynTrait, sabi_extern_fn, rtry, }; use std::io::Write; #[sabi_extern_fn] pub fn write_slice_twice( mut write:DynTrait<&mut (),IoWriteInterface>, slice:&[u8], )->RResult<(),RIoError>{ rtry!( write.write_all(slice).into_c() ); rtry!( write.write_all(slice).into_c() ); ROk(()) }
Implementations
impl RIoError
[src]
pub fn new<E>(kind: ErrorKind, error: E) -> Self where
E: ErrorTrait + Send + Sync + 'static,
[src]
E: ErrorTrait + Send + Sync + 'static,
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());
pub fn new_<E>(kind: ErrorKind, error: E) -> Self where
E: Into<Box<dyn ErrorTrait + Send + Sync + 'static>>,
[src]
E: Into<Box<dyn ErrorTrait + Send + Sync + 'static>>,
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);
pub fn from_kind(kind: ErrorKind) -> Self
[src]
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 );
pub fn with_box(
kind: ErrorKind,
error: Box<dyn ErrorTrait + Send + Sync + 'static>
) -> Self
[src]
kind: ErrorKind,
error: Box<dyn ErrorTrait + Send + Sync + 'static>
) -> Self
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());
pub fn with_rboxerror(kind: ErrorKind, error: RBoxError) -> Self
[src]
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() );
pub fn kind(&self) -> RIoErrorKind
[src]
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);
pub fn get_ref(&self) -> Option<&RBoxError>
[src]
Gets the internal error,
returning None
if this was constructed with RIoError::from_kind
.
Example
use abi_stable::std_types::{RIoError,RIoErrorKind,RBoxError}; 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()); }
pub fn get_mut(&mut self) -> Option<&mut RBoxError>
[src]
Gets the internal error,
returning None
if this was constructed with RIoError::from_kind
.
Example
use abi_stable::std_types::{RIoError,RIoErrorKind,RBoxError}; 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()); }
pub fn into_inner(self) -> Option<RBoxError>
[src]
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
impl Debug for RIoError
[src]
impl Display for RIoError
[src]
impl Error for RIoError
[src]
pub fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
pub fn backtrace(&self) -> Option<&Backtrace>
[src]
pub fn description(&self) -> &str
1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl From<Error> for RIoError
[src]
impl From<ErrorKind> for RIoError
[src]
impl From<RIoErrorKind> for RIoError
[src]
pub fn from(kind: RIoErrorKind) -> Self
[src]
impl GetStaticEquivalent_ for RIoError
[src]
type StaticEquivalent = _static_RIoError
impl Into<Error> for RIoError
[src]
impl IntoReprRust for RIoError
[src]
impl StableAbi for RIoError
[src]
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
pub const LAYOUT: &'static TypeLayout
[src]
pub const ABI_CONSTS: AbiConsts
[src]
Auto Trait Implementations
impl RefUnwindSafe for RIoError
impl Send for RIoError
impl Sync for RIoError
impl Unpin for RIoError
impl UnwindSafe for RIoError
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> GetWithMetadata for T
[src]
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SelfOps for T where
T: ?Sized,
[src]
T: ?Sized,
pub const T: PhantomData<fn() -> Self>
[src]
pub const T_D: PhantomData<Self>
[src]
pub fn assert_ty(self, _other: PhantomData<fn() -> Self>) -> Self
[src]
pub fn assert_ty_ref(&self, _other: PhantomData<fn() -> Self>) -> &Self
[src]
pub fn assert_ty_mut(&mut self, _other: PhantomData<fn() -> Self>) -> &mut Self
[src]
pub fn ty_(&self) -> PhantomData<fn() -> Self>
[src]
pub fn ty_d(&self) -> PhantomData<Self>
[src]
pub fn ty_inv(&self) -> PhantomData<fn(Self) -> Self>
[src]
pub fn ty_inv_ref(&self) -> PhantomData<Cell<&Self>>
[src]
pub fn eq_id(&self, other: &Self) -> bool
[src]
pub fn piped<F, U>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
pub fn piped_ref<'a, F, U>(&'a self, f: F) -> U where
F: FnOnce(&'a Self) -> U,
[src]
F: FnOnce(&'a Self) -> U,
pub fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U where
F: FnOnce(&'a mut Self) -> U,
[src]
F: FnOnce(&'a mut Self) -> U,
pub fn mutated<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
pub fn observe<F>(self, f: F) -> Self where
F: FnOnce(&Self),
[src]
F: FnOnce(&Self),
pub fn into_<T>(self, PhantomData<fn() -> T>) -> T where
Self: Into<T>,
[src]
Self: Into<T>,
pub fn as_ref_<T>(&self) -> &T where
Self: AsRef<T>,
T: ?Sized,
[src]
Self: AsRef<T>,
T: ?Sized,
pub fn as_mut_<T>(&mut self) -> &mut T where
Self: AsMut<T>,
T: ?Sized,
[src]
Self: AsMut<T>,
T: ?Sized,
pub fn drop_(self)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<This> TransmuteElement for This where
This: ?Sized,
[src]
This: ?Sized,
pub unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
Self::Target: Sized,
[src]
Self: CanTransmuteElement<T>,
Self::Target: Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> TypeIdentity for T where
T: ?Sized,
[src]
T: ?Sized,
type Type = T
The same type as Self. Read more
pub fn into_type_val(self) -> Self::Type where
Self::Type: Sized,
[src]
Self::Type: Sized,
pub fn into_type_ref(&self) -> &Self::Type
[src]
pub fn into_type_mut(&mut self) -> &mut Self::Type
[src]
pub fn into_type_box(self: Box<Self, Global>) -> Box<Self::Type, Global>
[src]
pub fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
[src]
pub fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
[src]
pub fn from_type_val(this: Self::Type) -> Self where
Self::Type: Sized,
[src]
Self::Type: Sized,