| 1 | //! Trait definitions. |
| 2 | |
| 3 | use crate::ObjectIdentifier; |
| 4 | |
| 5 | /// A trait which associates an OID with a type. |
| 6 | pub 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`]. |
| 16 | pub trait DynAssociatedOid { |
| 17 | /// Get the OID associated with this value. |
| 18 | fn oid(&self) -> ObjectIdentifier; |
| 19 | } |
| 20 | |
| 21 | impl<T: AssociatedOid> DynAssociatedOid for T { |
| 22 | fn oid(&self) -> ObjectIdentifier { |
| 23 | T::OID |
| 24 | } |
| 25 | } |