const-oid: add ObjectIdentifierRef
#1305
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.