Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an iterator for CertificateChain #672

Merged
merged 3 commits into from
Mar 12, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions quinn-proto/src/crypto/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ impl CertificateChain {
pub fn from_certs(certs: impl IntoIterator<Item = Certificate>) -> Self {
certs.into_iter().collect()
}

/// An iterator over the certificates in the chain
pub fn iter(&self) -> impl Iterator<Item = &rustls::Certificate> {
self.certs.iter()
}
Ralith marked this conversation as resolved.
Show resolved Hide resolved
}

impl std::iter::FromIterator<Certificate> for CertificateChain {
Expand All @@ -71,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