1use core::fmt::Debug;
2
3pub trait Eth {
4 type Error: Debug;
5
6 fn start(&mut self) -> Result<(), Self::Error>;
7 fn stop(&mut self) -> Result<(), Self::Error>;
8
9 fn is_started(&self) -> Result<bool, Self::Error>;
10 fn is_connected(&self) -> Result<bool, Self::Error>;
11}
12
13impl<E> Eth for &mut E
14where
15 E: Eth,
16{
17 type Error = E::Error;
18
19 fn start(&mut self) -> Result<(), Self::Error> {
20 (*self).start()
21 }
22
23 fn stop(&mut self) -> Result<(), Self::Error> {
24 (*self).stop()
25 }
26
27 fn is_started(&self) -> Result<bool, Self::Error> {
28 (**self).is_started()
29 }
30
31 fn is_connected(&self) -> Result<bool, Self::Error> {
32 (**self).is_connected()
33 }
34}
35
36pub mod asynch {
37 use super::*;
38
39 pub trait Eth {
40 type Error: Debug;
41
42 async fn start(&mut self) -> Result<(), Self::Error>;
43 async fn stop(&mut self) -> Result<(), Self::Error>;
44
45 async fn is_started(&self) -> Result<bool, Self::Error>;
46 async fn is_connected(&self) -> Result<bool, Self::Error>;
47 }
48
49 impl<E> Eth for &mut E
50 where
51 E: Eth,
52 {
53 type Error = E::Error;
54
55 async fn start(&mut self) -> Result<(), Self::Error> {
56 (**self).start().await
57 }
58
59 async fn stop(&mut self) -> Result<(), Self::Error> {
60 (**self).stop().await
61 }
62
63 async fn is_started(&self) -> Result<bool, Self::Error> {
64 (**self).is_started().await
65 }
66
67 async fn is_connected(&self) -> Result<bool, Self::Error> {
68 (**self).is_connected().await
69 }
70 }
71}