xmtp_api_d14n/protocol/traits/
extractor.rs1pub trait Extractor {
5 type Output;
7 fn get(self) -> Self::Output;
9}
10
11pub trait TryExtractor: Extractor<Output = Result<Self::Ok, Self::Error>> {
15 type Ok;
17 type Error;
19 fn try_get(self) -> Result<Self::Ok, Self::Error>;
21}
22
23impl<T, O, Err> TryExtractor for T
24where
25 T: Extractor<Output = Result<O, Err>>,
26{
27 type Ok = O;
28
29 type Error = Err;
30
31 fn try_get(self) -> Result<Self::Ok, Self::Error> {
32 self.get()
33 }
34}
35
36pub trait MaybeExtractor: Extractor<Output = Option<Self::Value>> {
37 type Value;
38 fn maybe_get(self) -> Option<Self::Value>;
39}
40
41impl<T, V> MaybeExtractor for T
42where
43 T: Extractor<Output = Option<V>>,
44{
45 type Value = V;
46
47 fn maybe_get(self) -> Option<Self::Value> {
48 self.get()
49 }
50}