agnostic_io/
std.rs

1pub use std::io::{Error, ErrorKind, Result};
2
3#[cfg(feature = "tokio")]
4#[cfg_attr(docsrs, doc(cfg(feature = "tokio-io")))]
5pub use tokio::io as tokio_io;
6#[cfg(feature = "tokio")]
7#[cfg_attr(docsrs, doc(cfg(feature = "tokio-io")))]
8pub use tokio_util::compat as tokio_compat;
9
10pub use futures_util::io as futures_io;
11
12/// Marker trait for types that implement `AsyncRead` and `AsyncWrite`.
13///
14/// When the `tokio` feature is enabled, this trait is implemented for types that implement
15/// `tokio::io::AsyncRead`, `tokio::io::AsyncWrite`, `futures::io::AsyncRead` and `futures::io::AsyncWrite`.
16///
17/// When the `tokio` feature is disabled, this trait is implemented for types that implement
18/// `futures::io::AsyncRead` and `futures::io::AsyncWrite`.
19#[cfg(not(feature = "tokio"))]
20pub trait AsyncReadWrite: futures_io::AsyncRead + futures_io::AsyncWrite {}
21
22#[cfg(not(feature = "tokio"))]
23impl<T: futures_io::AsyncRead + futures_io::AsyncWrite> AsyncReadWrite for T {}
24
25/// Marker trait for types that implement `AsyncRead` and `AsyncWrite`.
26///
27/// When the `tokio` feature is enabled, this trait is implemented for types that implement
28/// `tokio::io::AsyncRead`, `tokio::io::AsyncWrite`, `futures::io::AsyncRead` and `futures::io::AsyncWrite`.
29///
30/// When the `tokio` feature is disabled, this trait is implemented for types that implement
31/// `futures::io::AsyncRead` and `futures::io::AsyncWrite`.
32#[cfg(feature = "tokio")]
33pub trait AsyncReadWrite:
34  ::tokio::io::AsyncRead + ::tokio::io::AsyncWrite + futures_io::AsyncRead + futures_io::AsyncWrite
35{
36}
37
38#[cfg(feature = "tokio")]
39impl<
40  T: ::tokio::io::AsyncRead + ::tokio::io::AsyncWrite + futures_io::AsyncRead + futures_io::AsyncWrite,
41> AsyncReadWrite for T
42{
43}
44
45/// Marker trait for types that implement `AsyncRead`.
46///
47/// When the `tokio` feature is enabled, this trait is implemented for types that implement
48/// `tokio::io::AsyncRead` and `futures::io::AsyncRead`.
49///
50/// When the `tokio` feature is disabled, this trait is implemented for types that implement
51/// `futures::io::AsyncRead`.
52#[cfg(not(feature = "tokio"))]
53pub trait AsyncRead: futures_io::AsyncRead {}
54
55#[cfg(not(feature = "tokio"))]
56impl<T: futures_io::AsyncRead> AsyncRead for T {}
57
58/// Marker trait for types that implement `AsyncRead`.
59///
60/// When the `tokio` feature is enabled, this trait is implemented for types that implement
61/// `tokio::io::AsyncRead` and `futures::io::AsyncRead`.
62///
63/// When the `tokio` feature is disabled, this trait is implemented for types that implement
64/// `futures::io::AsyncRead`.
65#[cfg(feature = "tokio")]
66pub trait AsyncRead: ::tokio::io::AsyncRead + futures_io::AsyncRead {}
67
68#[cfg(feature = "tokio")]
69impl<T: ::tokio::io::AsyncRead + futures_io::AsyncRead> AsyncRead for T {}
70
71/// Marker trait for types that implement `AsyncWrite`.
72///
73/// When the `tokio` feature is enabled, this trait is implemented for types that implement
74/// `tokio::io::AsyncWrite` and `futures::io::AsyncWrite`.
75///
76/// When the `tokio` feature is disabled, this trait is implemented for types that implement
77/// `futures::io::AsyncWrite`.
78#[cfg(not(feature = "tokio"))]
79pub trait AsyncWrite: futures_io::AsyncWrite {}
80
81#[cfg(not(feature = "tokio"))]
82impl<T: futures_io::AsyncWrite> AsyncWrite for T {}
83
84/// Marker trait for types that implement `AsyncWrite`.
85///
86/// When the `tokio` feature is enabled, this trait is implemented for types that implement
87/// `tokio::io::AsyncWrite` and `futures::io::AsyncWrite`.
88///
89/// When the `tokio` feature is disabled, this trait is implemented for types that implement
90/// `futures::io::AsyncWrite`.
91#[cfg(feature = "tokio")]
92pub trait AsyncWrite: ::tokio::io::AsyncWrite + futures_io::AsyncWrite {}
93
94#[cfg(feature = "tokio")]
95impl<T: ::tokio::io::AsyncWrite + futures_io::AsyncWrite> AsyncWrite for T {}