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
52
53
54
55
56
57
58
59
60
61
62
//! Alternative implementation of many functions found in [`std::io`],
//! but suitable for blocking IO over networks.
//!
//! The main reason for this crate is the handling of [`ErrorKind`]`::Interrupted` in
//! `std::io`.
//! Except for [`std::io::Read::read`] and [`std::io::Write::write`], almost all functions
//! will ignore interrupts and just retry.
//!
//! This crate provides alternative implementations using a similar API but allow for interrupts
//! whithout losing any content.
//!
//! Most functions are based on buffered readers instead of plain readers to ensure that no
//! content is lost on retry.
//!
//! [`std::io`]: https://doc.rust-lang.org/nightly/std/io/index.html
//! [`ErrorKind`]: https://doc.rust-lang.org/nightly/std/io/enum.ErrorKind.html
//! [`std::io::Read::read`]: https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read
//! [`std::io::Write::write`]:
//!     https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.write

extern crate memchr;
pub extern crate buf_redux;

mod impls;
mod adapt;
mod iter;
mod utf8;
mod stream;
mod read;
mod write;
mod bufread;
mod bufreadgrow;
mod copy;

pub mod mock;

use buf_redux as br;

pub use stream::Stream;
pub use read::Read;
pub use write::Write;
pub use bufread::BufRead;
pub use bufreadgrow::BufReadGrow;
pub use copy::{copy, copy_until};
pub use adapt::{Retry, Take, Repeat, Chain, Compat};
pub use iter::{Bytes, Split, Collect};
pub use utf8::Utf8Reader;

pub use std::io::{Result, Error, ErrorKind};

pub trait IoExt {
    fn compat(self) -> Compat<Self>
        where Self: Sized
    {
        Compat::new(self)
    }
}

impl<T> IoExt for T {}

/// Alternative to `std::io::BufReader`
pub type BufReader<R> = br::BufReader<R>;