countio

Build Status Crate Docs Crate Version Crate Coverage

Also check out other xwde projects here.

The wrapper struct to enable byte counting for std::io::Read, std::io::Write, std::io::Seek and its asynchronous variants from futures and tokio crates.

Features

Examples

```rust use std::io::{BufRead, BufReader, Result}; use countio::Counter;

fn main() -> Result<()> { let reader = "Hello World!".as_bytes(); let reader = BufReader::new(reader); let mut reader = Counter::new(reader);

let mut buf = String::new();
let len = reader.read_line(&mut buf)?;

assert_eq!(len, reader.reader_bytes());
Ok(())

} ```

```rust use std::io::{BufWriter, Write, Result}; use countio::Counter;

fn main() -> Result<()> { let writer = Vec::new(); let writer = BufWriter::new(writer); let mut writer = Counter::new(writer);

let buf = "Hello World!".as_bytes();
let len = writer.write(buf)?;
writer.flush()?;

assert_eq!(len, writer.writer_bytes());
Ok(())

} ```

Crates