warg_protobuf/
lib.rs

1#![allow(clippy::all, unused_qualifications)]
2
3pub mod protocol {
4    // Generated by [`prost-build`]
5    include!(concat!(env!("OUT_DIR"), "/warg.protocol.rs"));
6    // Generated by [`pbjson-build`]
7    include!(concat!(env!("OUT_DIR"), "/warg.protocol.serde.rs"));
8}
9
10pub mod transparency {
11    use anyhow::Error;
12    use warg_crypto::hash::{Hash, SupportedDigest};
13
14    // Generated by [`prost-build`]
15    include!(concat!(env!("OUT_DIR"), "/warg.transparency.rs"));
16    // Generated by [`pbjson-build`]
17    include!(concat!(env!("OUT_DIR"), "/warg.transparency.serde.rs"));
18
19    impl<D> From<Option<Hash<D>>> for OptionalHash
20    where
21        D: SupportedDigest,
22    {
23        fn from(value: Option<Hash<D>>) -> Self {
24            Self {
25                hash: value.map(|h| h.bytes().to_vec()),
26            }
27        }
28    }
29    impl<D> TryFrom<OptionalHash> for Option<Hash<D>>
30    where
31        D: SupportedDigest,
32    {
33        type Error = Error;
34
35        fn try_from(value: OptionalHash) -> Result<Self, Self::Error> {
36            let hash = match value.hash {
37                Some(h) => Some(h.try_into()?),
38                None => None,
39            };
40            Ok(hash)
41        }
42    }
43}
44
45pub mod internal {
46    // Generated by [`prost-build`]
47    include!(concat!(env!("OUT_DIR"), "/warg.internal.rs"));
48    // Generated by [`pbjson-build`]
49    include!(concat!(env!("OUT_DIR"), "/warg.internal.serde.rs"));
50}