xwt_anchor/impls/xwt_core/
streams.rs1use core::num::NonZeroUsize;
4
5use crate::types::*;
6
7impl<T> xwt_core::stream::Write for SendStream<T>
8where
9 T: xwt_core::stream::Write,
10{
11 type Error = T::Error;
12
13 async fn write(&mut self, buf: &[u8]) -> Result<NonZeroUsize, Self::Error> {
14 T::write(&mut self.0, buf).await
15 }
16}
17
18impl<T> xwt_core::stream::WriteAbort for SendStream<T>
19where
20 T: xwt_core::stream::WriteAbort,
21{
22 type Error = T::Error;
23
24 async fn abort(self, error_code: xwt_core::stream::ErrorCode) -> Result<(), Self::Error> {
25 T::abort(self.0, error_code).await
26 }
27}
28
29impl<T> xwt_core::stream::WriteAborted for SendStream<T>
30where
31 T: xwt_core::stream::WriteAborted,
32{
33 type Error = T::Error;
34
35 async fn aborted(self) -> Result<xwt_core::stream::ErrorCode, Self::Error> {
36 T::aborted(self.0).await
37 }
38}
39
40impl<T> xwt_core::stream::Finish for SendStream<T>
41where
42 T: xwt_core::stream::Finish,
43{
44 type Error = T::Error;
45
46 async fn finish(self) -> Result<(), Self::Error> {
47 T::finish(self.0).await
48 }
49}
50
51impl<T> xwt_core::stream::Finished for RecvStream<T>
52where
53 T: xwt_core::stream::Finished,
54{
55 type Error = T::Error;
56
57 async fn finished(self) -> Result<(), Self::Error> {
58 T::finished(self.0).await
59 }
60}
61
62impl<T> xwt_core::stream::Read for RecvStream<T>
63where
64 T: xwt_core::stream::Read,
65{
66 type Error = T::Error;
67
68 async fn read(&mut self, buf: &mut [u8]) -> Result<NonZeroUsize, Self::Error> {
69 T::read(&mut self.0, buf).await
70 }
71}
72
73impl<T> xwt_core::stream::ReadAbort for RecvStream<T>
74where
75 T: xwt_core::stream::ReadAbort,
76{
77 type Error = T::Error;
78
79 async fn abort(self, error_code: xwt_core::stream::ErrorCode) -> Result<(), Self::Error> {
80 T::abort(self.0, error_code).await
81 }
82}
83
84impl<T> xwt_core::stream::ReadAborted for RecvStream<T>
85where
86 T: xwt_core::stream::ReadAborted,
87{
88 type Error = T::Error;
89
90 async fn aborted(self) -> Result<xwt_core::stream::ErrorCode, Self::Error> {
91 T::aborted(self.0).await
92 }
93}