async_proto/impls/
gix_hash.rs

1use {
2    gix_hash::ObjectId,
3    async_proto_derive::impl_protocol_for,
4    crate::Protocol,
5};
6
7#[derive(Protocol)]
8#[async_proto(internal)]
9struct OidProxy([u8; 20]);
10
11impl From<OidProxy> for ObjectId {
12    fn from(OidProxy(sha1): OidProxy) -> Self {
13        Self::Sha1(sha1)
14    }
15}
16
17impl<'a> From<&'a ObjectId> for OidProxy {
18    fn from(oid: &ObjectId) -> Self {
19        match *oid {
20            ObjectId::Sha1(sha1) => Self(sha1),
21        }
22    }
23}
24
25impl_protocol_for! {
26    #[async_proto(attr(cfg_attr(docsrs, doc(cfg(feature = "gix-hash")))))]
27    #[async_proto(via = OidProxy)]
28    type ObjectId;
29}