1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! The wrapper struct to enable byte counting for [std::io::Read] and
//! [std::io::Write] and its asynchronous variants from `futures` and `tokio`
//! crates.
//!
//! **Also check out other `xwde` projects [here](https://github.com/xwde).**
//!
//! ## Features
//!
//! - `std` to enable [std::io::Read] and [std::io::Write]. **Enabled by default**.
//! - `futures` to enable [futures_io::AsyncRead] and [futures_io::AsyncWrite].
//! - `tokio` to enable [tokio::io::AsyncRead] and [tokio::io::AsyncWrite].
//!
//! ## Examples
//!
//! - `std::io::Read`:
//!
//! ```rust
//! use std::io::{BufRead, BufReader};
//! use countio::Counter;
//!
//! let reader = "Hello World!".as_bytes();
//! let reader = Counter::new(reader);
//! let mut reader = BufReader::new(reader);
//!
//! let mut buf = String::new();
//! let len = reader.read_line(&mut buf).unwrap();
//!
//! assert_eq!(len, reader.get_ref().reader_bytes());
//! ```
//!
//! - `std::io::Write`:
//!
//! ```rust
//! use std::io::{BufWriter, Write};
//! use countio::Counter;
//!
//! let writer = Vec::new();
//! let writer = Counter::new(writer);
//! let mut writer = BufWriter::new(writer);
//!
//! let buf = "Hello World!".as_bytes();
//! let len = writer.write(buf).unwrap();
//! writer.flush().unwrap();
//!
//! assert_eq!(len, writer.get_ref().writer_bytes());
//! ```
pub use *;