webtransport_generic/
send.rs1use std::{
2 future::{poll_fn, Future},
3 task::{Context, Poll},
4};
5
6use bytes::Buf;
7
8use crate::ErrorCode;
9
10pub trait SendStream: Unpin + Send {
12 type Error: ErrorCode;
13
14 fn priority(&mut self, order: i32);
18
19 fn close(self, code: u32);
21
22 fn poll_write(&mut self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, Self::Error>>;
24
25 fn write(&mut self, buf: &[u8]) -> impl Future<Output = Result<usize, Self::Error>> + Send {
27 poll_fn(|cx| self.poll_write(cx, buf))
28 }
29
30 fn poll_write_buf<B: Buf>(
31 &mut self,
32 cx: &mut Context<'_>,
33 buf: &mut B,
34 ) -> Poll<Result<usize, Self::Error>>;
35
36 fn write_buf<B: Buf + Send>(
38 &mut self,
39 buf: &mut B,
40 ) -> impl Future<Output = Result<usize, Self::Error>> + Send {
41 poll_fn(|cx| self.poll_write_buf(cx, buf))
42 }
43
44 }