Closed tarcieri closed 6 months ago
An unsafe pointer cast is required to go from &[u8] to &ObjectIdentifierRef, so unfortunately this means the crate is no longer forbid(unsafe_code)
Sidebar: really wish these could eventually be "safe transmutes"
Adds a
repr(transparent)
newtype for a[u8]
which is guaranteed to contain a valid BER serialization of an OID. This is a similar approach to howPath
/PathBuf
orOsStr
/OsString
work (except withObjectIdentifier
being stack-allocated instead of heap allocated).An unsafe pointer cast is required to go from
&[u8]
to&ObjectIdentifierRef
, so unfortunately this means the crate is no longerforbid(unsafe_code)
, however it's been lowered todeny(unsafe_code)
to ensure contributors think twice before adding more.Borrow
andDeref
impls have been added to the ownedObjectIdentifier
type, allowing common functionality to be moved toObjectIdentifierRef
, allowing both types to exist while eliminating code duplication.A
PartialEq
impl allows them to be compared.The
db
module continues to useObjectIdentifier
for now, however hopefully this approach would allow #1212 to be reinstated and forObjectIdentifierRef
s to be used for the database eventually (i.e. revert the revert in #1299)NOTE: this PR also relaxes the previous requirement that an OID have at least three arcs. It is now allowed to only have two. It also removes the
Error::NotEnoughArcs
variant that covered that particular case.