1use embedded_io_async::ErrorType;
4
5use crate::raw::{RawReceive, RawSend};
6use crate::Readable;
7
8pub trait RawSplit: ErrorType {
11 type Receive<'a>: RawReceive<Error = Self::Error> + Readable<Error = Self::Error>
12 where
13 Self: 'a;
14 type Send<'a>: RawSend<Error = Self::Error>
15 where
16 Self: 'a;
17
18 fn split(&mut self) -> (Self::Receive<'_>, Self::Send<'_>);
19}
20
21impl<T> RawSplit for &mut T
22where
23 T: RawSplit,
24{
25 type Receive<'a>
26 = T::Receive<'a>
27 where
28 Self: 'a;
29 type Send<'a>
30 = T::Send<'a>
31 where
32 Self: 'a;
33
34 fn split(&mut self) -> (Self::Receive<'_>, Self::Send<'_>) {
35 (**self).split()
36 }
37}
38
39pub trait RawBind {
42 type Error: embedded_io_async::Error;
44
45 type Socket<'a>: RawReceive<Error = Self::Error>
47 + RawSend<Error = Self::Error>
48 + RawSplit<Error = Self::Error>
49 + Readable<Error = Self::Error>
50 where
51 Self: 'a;
52
53 async fn bind(&self) -> Result<Self::Socket<'_>, Self::Error>;
57}
58
59impl<T> RawBind for &T
60where
61 T: RawBind,
62{
63 type Error = T::Error;
64
65 type Socket<'a>
66 = T::Socket<'a>
67 where
68 Self: 'a;
69
70 async fn bind(&self) -> Result<Self::Socket<'_>, Self::Error> {
71 (*self).bind().await
72 }
73}
74
75impl<T> RawBind for &mut T
76where
77 T: RawBind,
78{
79 type Error = T::Error;
80
81 type Socket<'a>
82 = T::Socket<'a>
83 where
84 Self: 'a;
85
86 async fn bind(&self) -> Result<Self::Socket<'_>, Self::Error> {
87 (**self).bind().await
88 }
89}