Skip to content

Commit

Permalink
spki: impl From<AlgorithmIdentifierRef> for Any
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed May 24, 2024
1 parent e28a8ea commit d918cb5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spki/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl<'a> AlgorithmIdentifierRef<'a> {
#[cfg(feature = "alloc")]
mod allocating {
use super::*;
use der::referenced::*;
use der::{referenced::*, Tag};

impl<'a> RefToOwned<'a> for AlgorithmIdentifierRef<'a> {
type Owned = AlgorithmIdentifierOwned;
Expand All @@ -196,4 +196,12 @@ mod allocating {
}
}
}

impl From<&AlgorithmIdentifierRef<'_>> for Any {
fn from(alg: &AlgorithmIdentifierRef<'_>) -> Any {
let bytes = alg.to_der().expect("Algorithm invariant violated");

Any::new(Tag::Sequence, bytes).expect("Algorithm invariant violated")
}
}
}

0 comments on commit d918cb5

Please sign in to comment.