Skip to content

Commit

Permalink
Make the representation of ObjectIdentifier more private.
Browse files Browse the repository at this point in the history
In preperation for #181
  • Loading branch information
alex committed Apr 23, 2022
1 parent 2782f8f commit 65011ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/object_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloc::vec::Vec;
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct ObjectIdentifier<'a> {
// Store the OID as DER encoded. This means we can 0-copy on parse.
pub(crate) der_encoded: Cow<'a, [u8]>,
der_encoded: Cow<'a, [u8]>,
}

fn _read_base128_int<I: Iterator<Item = u8>>(mut reader: I) -> Option<u32> {
Expand Down Expand Up @@ -86,6 +86,10 @@ impl<'a> ObjectIdentifier<'a> {
der_encoded: Cow::Borrowed(data),
})
}

pub(crate) fn as_der(&self) -> &[u8] {
&self.der_encoded
}
}

impl fmt::Display for ObjectIdentifier<'_> {
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ impl<'a> SimpleAsn1Readable<'a> for ObjectIdentifier<'a> {
impl<'a> SimpleAsn1Writable<'a> for ObjectIdentifier<'a> {
const TAG: u8 = 0x06;
fn write_data(&self, dest: &mut Vec<u8>) {
dest.extend_from_slice(&self.der_encoded);
dest.extend_from_slice(&self.as_der());
}
}

Expand Down

0 comments on commit 65011ae

Please sign in to comment.