Skip to content

Commit

Permalink
Iterators over the (rustls) certificates in a CertificateChain
Browse files Browse the repository at this point in the history
  • Loading branch information
kim committed Mar 11, 2020
1 parent ab68414 commit 8cf8b5a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions quinn-proto/src/crypto/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ impl CertificateChain {
certs.into_iter().collect()
}

/// Iterate over the certificates
pub fn iter<'a>(&'a self) -> impl Iterator<Item = Certificate> + 'a {
self.certs
.iter()
.cloned()
.map(|cert| Certificate { inner: cert })
/// An iterator over the certificates in the chain
pub fn iter(&self) -> impl Iterator<Item = &rustls::Certificate> {
self.certs.iter()
}
}

Expand All @@ -79,6 +76,15 @@ impl From<Vec<rustls::Certificate>> for CertificateChain {
}
}

impl IntoIterator for CertificateChain {
type Item = rustls::Certificate;
type IntoIter = std::vec::IntoIter<rustls::Certificate>;

fn into_iter(self) -> Self::IntoIter {
self.certs.into_iter()
}
}

/// The private key of a TLS certificate to be used by a server
#[derive(Debug, Clone)]
pub struct PrivateKey {
Expand Down

0 comments on commit 8cf8b5a

Please sign in to comment.