#io-write #overlay #io-read #read-write #io

slice

slices for streams implementing std::io::read and std::io::write

4 releases

Uses old Rust 2015

0.0.4 Aug 7, 2018
0.0.3 Apr 2, 2018
0.0.2 Aug 14, 2017
0.0.1 Apr 27, 2017

#1671 in Filesystem

Download history 4/week @ 2024-08-11 7/week @ 2024-08-25 2/week @ 2024-09-01 12/week @ 2024-09-08 22/week @ 2024-09-15 11/week @ 2024-09-22 19/week @ 2024-09-29 3/week @ 2024-10-13 13/week @ 2024-10-20 1/week @ 2024-10-27 12/week @ 2024-11-03 29/week @ 2024-11-10

55 downloads per month
Used in 2 crates (via posy)

MIT/Apache

11KB
134 lines

slice.

create slices of io objects std::io::Read and std::io::Write.

if you have a file (or any other object), you can create a slice (or view) into some subset of it.

IoSlice impls both std::io::Read and std::io::Write when the source implements them (and only one if the source only implements one).

example usage.

use { std::fs::File, slice::IoSlice };


let source = File::open("/home/annie/data.png")?;
let start  = 10;
let length = 1000;


// create a slice into `home/annie/data.png`, consisting of bytes [10 .. 10 + 1000]
// of that file.
//
// `slice` impls both `std::io::Read` and `std::io::Write` because `source`
// does too.
let slice = IoSlice::new(source, start, length);


// use like any other `std::io::Read` or `std::io::Write`:
//
//     slice.read_to_string(...)?;
//     slice.read_exact(...)?;
//     slice.write_all(...)?;
//
//     writeln!(slice, "hello {}", name)?;
//

lib.rs:

Create slices of IO objects - std::io::Read and std::io::Write.

If you have a file (or any other object), you can create a slice (or view) into some subset of it.

IoSlice impls both std::io::Read and std::io::Write when the source implements them (and only one if the source only implements one).

example usage.

use { std::fs::File, slice::IoSlice };


let source = File::open("/home/annie/data.png")?;
let start  = 10;
let length = 1000;


// create a slice into `home/annie/data.png`, consisting of bytes [10 .. 10 + 1000]
// of that file.
//
// `slice` impls both `std::io::Read` and `std::io::Write` because `source`
// does too.
let slice = IoSlice::new(source, start, length);


// use like any other `std::io::Read` or `std::io::Write`:
//
//     slice.read_to_string(...)?;
//     slice.read_exact(...)?;
//     slice.write_all(...)?;
//
//     writeln!(slice, "hello {}", name)?;
//

No runtime deps