Intentionally return short reads, to test Read
code.
The decider
iterator gets to decide how short a read should be.
A read length of 0 generates an ErrorKind::Interrupted
error.
When the iterator runs out before the reader, read
will always
return zero-length reads (EOF).
Currently, no effort is made to make reads longer, if the underlying
reader naturally returns short reads.
Short read:
let mut naughty = iowrap::ShortRead::new(
io::Cursor::new(b"1234567890"),
vec![2, 3, 4, 5, 6].into_iter()
);
let mut buf = [0u8; 10];
assert_eq!(2, naughty.read(&mut buf).unwrap());
Interrupted read:
let mut interrupting = iowrap::ShortRead::new(
io::Cursor::new(b"123"),
vec![0, 1, 0].into_iter()
);
let mut buf = [0u8; 10];
assert_eq!(io::ErrorKind::Interrupted,
interrupting.read(&mut buf).unwrap_err().kind());
pub fn new(inner: R, decider: I) -> Self | [src] |
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
🔬 This is a nightly-only experimental API. (read_initializer
)
Determines if this Read
er can work with buffers of uninitialized memory. Read more
Read all bytes until EOF in this source, placing them into buf
. Read more
Read all bytes until EOF in this source, appending them to buf
. Read more
Read the exact number of bytes required to fill buf
. Read more
Creates a "by reference" adaptor for this instance of Read
. Read more
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
Creates an adaptor which will chain this stream with another. Read more
Creates an adaptor which will read at most limit
bytes from it. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static