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
use std::io;

use nio::{ReadV, WriteV};

pub trait AsyncRead: io::Read + ReadV {
    fn need_read(&mut self) -> io::Result<()>;

    fn no_need_read(&mut self) -> io::Result<()>;

    fn is_readable(&self) -> bool;
}

pub trait AsyncWrite: io::Write + WriteV {
    fn need_write(&mut self) -> io::Result<()>;

    fn no_need_write(&mut self) -> io::Result<()>;

    fn is_writable(&self) -> bool;
}

impl<'a, R: AsyncRead> AsyncRead for &'a mut R {
    #[inline]
    fn need_read(&mut self) -> io::Result<()> {
        AsyncRead::need_read(*self)
    }

    #[inline]
    fn no_need_read(&mut self) -> io::Result<()> {
        AsyncRead::no_need_read(*self)
    }

    #[inline]
    fn is_readable(&self) -> bool {
        AsyncRead::is_readable(*self)
    }
}

impl<'a, W: AsyncWrite> AsyncWrite for &'a mut W {
    #[inline]
    fn need_write(&mut self) -> io::Result<()> {
        AsyncWrite::need_write(*self)
    }

    #[inline]
    fn no_need_write(&mut self) -> io::Result<()> {
        AsyncWrite::no_need_write(*self)
    }

    #[inline]
    fn is_writable(&self) -> bool {
        AsyncWrite::is_writable(*self)
    }
}

mod util;

pub use self::util::{IStream, OStream};
pub use self::util::read::*;
pub use self::util::write::*;
pub use self::util::copy::*;
pub use self::util::split::*;