use core::future::Future;
pub mod blocking;
pub mod local_lock;
#[cfg(any(test, feature = "io-test-utils"))]
pub mod cursor;
#[cfg(any(test, feature = "io-test-utils"))]
pub mod mem_pipe;
#[cfg(feature = "futures-io")]
pub mod futures_io;
#[cfg(feature = "tokio-io")]
pub mod tokio_io;
pub use blocking::BlockingIo;
pub use local_lock::LocalLock;
pub trait AsyncBytesRead {
type Error;
fn read_exact(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<(), Self::Error>>;
}
pub trait AsyncBytesWrite {
type Error;
fn write_all(&mut self, buf: &[u8]) -> impl Future<Output = Result<(), Self::Error>>;
fn flush(&mut self) -> impl Future<Output = Result<(), Self::Error>>;
}
impl<T: AsyncBytesRead + ?Sized> AsyncBytesRead for &mut T {
type Error = T::Error;
fn read_exact(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<(), Self::Error>> {
(**self).read_exact(buf)
}
}
impl<T: AsyncBytesWrite + ?Sized> AsyncBytesWrite for &mut T {
type Error = T::Error;
fn write_all(&mut self, buf: &[u8]) -> impl Future<Output = Result<(), Self::Error>> {
(**self).write_all(buf)
}
fn flush(&mut self) -> impl Future<Output = Result<(), Self::Error>> {
(**self).flush()
}
}