Crates.io | arc-io-error |
lib.rs | arc-io-error |
version | 0.1.1 |
source | src |
created_at | 2017-08-10 23:25:39.85825 |
updated_at | 2017-08-11 17:14:43.992967 |
description | A version of std::io::Error implemented on top of Arc instead of Box, making it cloneable. |
homepage | https://github.com/spinda/arc-io-error |
repository | https://github.com/spinda/arc-io-error |
max_upload_size | |
id | 27116 |
size | 31,760 |
This library provides the
IoError
type, a version of
std::io::Error
implemented on top of
Arc
instead
of Box
,
making it cloneable.
First, add this to your Cargo.toml
:
[dependencies]
arc-io-error = "0.1.1"
Next, add this to your crate:
extern crate arc_io_error;
use arc_io_error::IoError;
The API of
IoError
has been designed to match
io::Error
,
with two exceptions:
IoError::new
and
IoError::into_inner
substitute
Arc
for
Box
, andIoError
has no equivalent to
io::Error::get_mut
,
as the inner error instance is shared.IoError
implements
From
for io::Error
and vice-versa, so the two types can easily be converted between each other.
A type containing
io::Error
can
be made
Clone
-compatible
by instead storing
IoError
internally and converting from/to
io::Error
on API
boundaries.
Clones derived from the same original
IoError
instance will share a single heap-allocated error instance (if one is
present) using
Arc
.
io::Error
instances produced by converting those clones back with the
From
implementation will also share the same single error instance.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.