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
use core::future::Future;
use crate::{Context, State};
/// A stream that can be written to asynchronously.
pub trait AsyncWrite {
/// The error returned by [`write`](Self::write) and [`flush`](Self::flush).
type Error;
/// Writes from a given buffer, returns the number of written bytes.
///
/// # Errors
///
/// Returns an error if writing fails.
///
/// # Cancel safety
///
/// Implementations in this crate are cancel safe.
fn write<
'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 [u8],
) -> impl Future<Output = Result<usize, Self::Error>>;
/// Makes sure that everything accepted by [`write`](Self::write) is sent.
///
/// # Errors
///
/// Returns an error if writing fails.
///
/// # Cancel safety
///
/// Implementations in this crate are cancel safe.
fn flush<
'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>,
) -> impl Future<Output = Result<(), Self::Error>>;
}