maybe_fut/unwrap.rs
1//! Unwrap trait for MaybeFut types.
2
3/// Unwrap trait for MaybeFut types.
4///
5/// This trait provides methods to get the underlying implementations for the MaybeFut wrappers.
6///
7/// Every type implemented by the **maybe_fut** library has a corresponding `Unwrap` implementation.
8pub trait Unwrap {
9 type StdImpl;
10 #[cfg(feature = "tokio")]
11 type TokioImpl;
12
13 /// Unwraps the std underlying implementation of the MaybeFut type.
14 fn unwrap_std(self) -> Self::StdImpl;
15
16 #[cfg(feature = "tokio")]
17 /// Unwraps the tokio underlying implementation of the MaybeFut type.
18 fn unwrap_tokio(self) -> Self::TokioImpl;
19
20 /// Unwraps the std underlying implementation of the MaybeFut type as a reference.
21 fn unwrap_std_ref(&self) -> &Self::StdImpl;
22
23 #[cfg(feature = "tokio")]
24 /// Unwraps the tokio underlying implementation of the MaybeFut type as a reference.
25 fn unwrap_tokio_ref(&self) -> &Self::TokioImpl;
26
27 /// Unwraps the std underlying implementation of the MaybeFut type as a mutable reference.
28 fn unwrap_std_mut(&mut self) -> &mut Self::StdImpl;
29
30 #[cfg(feature = "tokio")]
31 /// Unwraps the tokio underlying implementation of the MaybeFut type as a mutable reference.
32 fn unwrap_tokio_mut(&mut self) -> &mut Self::TokioImpl;
33
34 /// Safely unwraps the std underlying implementation of the MaybeFut type.
35 fn get_std(self) -> Option<Self::StdImpl>;
36
37 #[cfg(feature = "tokio")]
38 /// Safely unwraps the tokio underlying implementation of the MaybeFut type.
39 fn get_tokio(self) -> Option<Self::TokioImpl>;
40
41 /// Safely unwraps the std underlying implementation of the MaybeFut type as a reference.
42 fn get_std_ref(&self) -> Option<&Self::StdImpl>;
43
44 #[cfg(feature = "tokio")]
45 /// Safely unwraps the tokio underlying implementation of the MaybeFut type as a reference.
46 fn get_tokio_ref(&self) -> Option<&Self::TokioImpl>;
47
48 /// Safely unwraps the std underlying implementation of the MaybeFut type as a mutable reference.
49 fn get_std_mut(&mut self) -> Option<&mut Self::StdImpl>;
50
51 #[cfg(feature = "tokio")]
52 /// Safely unwraps the tokio underlying implementation of the MaybeFut type as a mutable reference.
53 fn get_tokio_mut(&mut self) -> Option<&mut Self::TokioImpl>;
54}