From 1d8ebffa26d1d265f6739a90dc7beb79f7f1a941 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Wed, 19 Jun 2024 16:44:16 -0400 Subject: [PATCH 1/2] add const CertificateDer::from_slice This commit adds the ability to construct a `const CertificateDer` by way of the `const`-friendly `CertificateDer::from_slice()` fn that accepts a slice of `&[u8]` DER. --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 16b660b..dd867f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,6 +71,7 @@ use std::time::SystemTime; use web_time::SystemTime; mod server_name; + pub use server_name::{ AddrParseError, DnsName, InvalidDnsNameError, IpAddr, Ipv4Addr, Ipv6Addr, ServerName, }; @@ -465,6 +466,13 @@ impl<'a> From> for CertificateSigningRequestDer<'a> { #[derive(Clone, Debug, PartialEq, Eq)] pub struct CertificateDer<'a>(Der<'a>); +impl<'a> CertificateDer<'a> { + /// A const constructor to create a `CertificateDer` from a slice of DER. + pub const fn from_slice(bytes: &'a [u8]) -> Self { + Self(Der::from_slice(bytes)) + } +} + impl AsRef<[u8]> for CertificateDer<'_> { fn as_ref(&self) -> &[u8] { self.0.as_ref() From ded523b3ce8dcfa4510daa1bcce07d9efbdce69b Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Wed, 19 Jun 2024 16:45:20 -0400 Subject: [PATCH 2/2] Cargo: version 1.7.0 -> 1.8.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fd5939c..b6babfe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" edition = "2021" rust-version = "1.60" license = "MIT OR Apache-2.0"