const_oid/traits.rs
1//! Trait definitions.
2
3use crate::ObjectIdentifier;
4
5/// A trait which associates an OID with a type.
6pub trait AssociatedOid {
7 /// The OID associated with this type.
8 const OID: ObjectIdentifier;
9}
10
11/// A trait which associates a dynamic, `&self`-dependent OID with a type,
12/// which may change depending on the type's value.
13///
14/// This trait is object safe and auto-impl'd for any types which impl
15/// [`AssociatedOid`].
16pub trait DynAssociatedOid {
17 /// Get the OID associated with this value.
18 fn oid(&self) -> ObjectIdentifier;
19}
20
21impl<T: AssociatedOid> DynAssociatedOid for T {
22 fn oid(&self) -> ObjectIdentifier {
23 T::OID
24 }
25}