partial-io
A Rust utility library to test resilience of Read
or Write
wrappers.
If you'd like to help out, see CONTRIBUTING.md.
Documentation (latest release)
Example
use ;
use ;
let data = b"Hello, world!".to_vec;
let cursor = new; // Cursor<Vec<u8>> implements io::Read
let ops = vec!;
let mut partial_read = new;
let mut out = vec!;
// The first read will read 7 bytes.
assert_eq!;
assert_eq!;
// The second read will fail with ErrorKind::Interrupted.
assert_eq!;
// The iterator has run out of operations, so it no longer truncates reads.
assert_eq!;
assert_eq!;
Quick start
Add this to your Cargo.toml
:
[]
= "0.3"
Next, add this to your crate:
extern crate partial_io;
Now you can use partial-io
in your tests.
Tokio integration
partial-io
can optionally integrate with the tokio-io
library to provide
wrappers for AsyncRead
and AsyncWrite
instances. Enable the tokio
feature
to use this:
[]
= { = "0.3", = ["tokio"] }
QuickCheck integration
partial-io
can optionally integrate with the quickcheck
library to generate
random test cases. Enable the quickcheck
feature to use this:
[]
= { = "0.3", = ["quickcheck"] }
See the
documentation
for how to use quickcheck
to generate tests.
License
partial-io
is MIT-licensed.