1use crate::Cid;
3use std::sync::Arc;
4
5pub trait AsCid {
7 fn as_cid(&self) -> &Cid;
9}
10
11impl AsCid for Cid {
12 fn as_cid(&self) -> &Cid {
13 self
14 }
15}
16
17impl<T> AsCid for &T
18where
19 T: AsCid,
20{
21 fn as_cid(&self) -> &Cid {
22 (*self).as_cid()
23 }
24}
25
26impl<T> AsCid for Arc<T>
27where
28 T: AsCid,
29{
30 fn as_cid(&self) -> &Cid {
31 self.as_ref().as_cid()
32 }
33}
34
35impl<T> AsCid for Box<T>
36where
37 T: AsCid,
38{
39 fn as_cid(&self) -> &Cid {
40 self.as_ref().as_cid()
41 }
42}