Skip to content

Commit

Permalink
Changed From<[u8]> to new()
Browse files Browse the repository at this point in the history
  • Loading branch information
bhesh committed Oct 25, 2023
1 parent f026906 commit 478cde4
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions x509-ocsp/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,13 @@ impl AsExtension for Nonce {
const CRITICAL: bool = false;
}

impl TryFrom<&[u8]> for Nonce {
type Error = der::Error;

fn try_from(data: &[u8]) -> Result<Self, Self::Error> {
Ok(Self(OctetString::new(data)?))
impl Nonce {
/// Creates a Nonce object given the bytes
pub fn new(bytes: impl Into<Vec<u8>>) -> Result<Self, der::Error> {
Ok(Self(OctetString::new(bytes)?))
}
}

impl Nonce {
/// Creates a new Nonce object given a random generator and a length
/// Creates a Nonce object given a random generator and a length
#[cfg(feature = "rand_core")]
pub fn generate<R: CryptoRngCore>(rng: &mut R, length: usize) -> Result<Self, der::Error> {
let mut bytes = Vec::with_capacity(length);
Expand Down

0 comments on commit 478cde4

Please sign in to comment.