1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#![allow(clippy::all, unused_qualifications)]

pub mod protocol {
    // Generated by [`prost-build`]
    include!(concat!(env!("OUT_DIR"), "/warg.protocol.rs"));
    // Generated by [`pbjson-build`]
    include!(concat!(env!("OUT_DIR"), "/warg.protocol.serde.rs"));
}

pub mod transparency {
    use anyhow::Error;
    use warg_crypto::hash::{Hash, SupportedDigest};

    // Generated by [`prost-build`]
    include!(concat!(env!("OUT_DIR"), "/warg.transparency.rs"));
    // Generated by [`pbjson-build`]
    include!(concat!(env!("OUT_DIR"), "/warg.transparency.serde.rs"));

    impl<D> From<Option<Hash<D>>> for OptionalHash
    where
        D: SupportedDigest,
    {
        fn from(value: Option<Hash<D>>) -> Self {
            Self {
                hash: value.map(|h| h.bytes().to_vec()),
            }
        }
    }
    impl<D> TryFrom<OptionalHash> for Option<Hash<D>>
    where
        D: SupportedDigest,
    {
        type Error = Error;

        fn try_from(value: OptionalHash) -> Result<Self, Self::Error> {
            let hash = match value.hash {
                Some(h) => Some(h.try_into()?),
                None => None,
            };
            Ok(hash)
        }
    }
}

pub mod internal {
    // Generated by [`prost-build`]
    include!(concat!(env!("OUT_DIR"), "/warg.internal.rs"));
    // Generated by [`pbjson-build`]
    include!(concat!(env!("OUT_DIR"), "/warg.internal.serde.rs"));
}