aral_runtime_noop/io/
mod.rs

1use std::{
2    future::Future,
3    io::{Result, SeekFrom},
4};
5
6pub trait Read {
7    fn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>> + Send;
8}
9
10impl<T: ?Sized + Read + Unpin + Send> Read for &mut T {
11    #[inline]
12    async fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
13        no_runtime_specified!();
14    }
15}
16
17impl<T: ?Sized + Read + Unpin + Send> Read for Box<T> {
18    #[inline]
19    async fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
20        no_runtime_specified!();
21    }
22}
23
24pub trait BufRead: Read {
25    fn fill_buf(&mut self) -> impl Future<Output = Result<&[u8]>> + Send;
26
27    fn consume(&mut self, amt: usize);
28}
29
30pub trait Write {
31    fn write(&mut self, buf: &[u8]) -> impl Future<Output = Result<usize>> + Send;
32
33    fn flush(&mut self) -> impl Future<Output = Result<()>> + Send;
34}
35
36pub trait Seek {
37    fn seek(&mut self, pos: SeekFrom) -> impl Future<Output = Result<u64>> + Send;
38}
39
40pub struct Empty;
41
42impl Read for Empty {
43    #[inline]
44    async fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
45        no_runtime_specified!();
46    }
47}
48
49impl BufRead for Empty {
50    #[inline]
51    async fn fill_buf(&mut self) -> Result<&[u8]> {
52        no_runtime_specified!();
53    }
54
55    #[inline]
56    fn consume(&mut self, _amt: usize) {
57        no_runtime_specified!();
58    }
59}
60
61#[inline]
62pub fn empty() -> Empty {
63    no_runtime_specified!();
64}