use core::future::Future;
use crate::{Context, State};
/// A stream that can be read from asynchronously.
pub trait AsyncRead {
/// The error returned by [`read`](Self::read).
type Error;
/// Reads into a given buffer, returns the number of read bytes.
///
/// Returns `0` if the stream is closed (or if the buffer is empty).
///
/// # Errors
///
/// Returns an error if reading fails.
///
/// # Cancel safety
///
/// Implementations in this crate are cancel safe.
fn read<
'a,
S: State,
const TASKS: usize,
const TASK_SIZE: usize,
const ROOT_TASK_SIZE: usize,
const TIMERS: usize,
const FDS: usize,
>(
&'a mut self,
ctx: &'a Context<'_, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>,
buf: &'a mut [u8],
) -> impl Future<Output = Result<usize, Self::Error>>;
}