Skip to content

Commit 5855e24

Browse files
lvkvcpu
authored andcommitted
Eagerly derive Clone where possible
1 parent e5203ef commit 5855e24

File tree

7 files changed

+18
-13
lines changed

7 files changed

+18
-13
lines changed

rcgen/src/crl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use crate::{
6464
/// key_identifier_method: KeyIdMethod::PreSpecified(vec![]),
6565
/// }.signed_by(&issuer_params, &key_pair).unwrap();
6666
///# }
67-
#[derive(Debug)]
67+
#[derive(Clone, Debug)]
6868
pub struct CertificateRevocationList {
6969
der: CertificateRevocationListDer<'static>,
7070
}
@@ -159,7 +159,7 @@ pub enum RevocationReason {
159159
}
160160

161161
/// Parameters used for certificate revocation list (CRL) generation
162-
#[derive(Debug)]
162+
#[derive(Clone, Debug)]
163163
pub struct CertificateRevocationListParams {
164164
/// Issue date of the CRL.
165165
pub this_update: OffsetDateTime,
@@ -293,7 +293,7 @@ impl CertificateRevocationListParams {
293293

294294
/// A certificate revocation list (CRL) issuing distribution point, to be included in a CRL's
295295
/// [issuing distribution point extension](https://datatracker.ietf.org/doc/html/rfc5280#section-5.2.5).
296-
#[derive(Debug)]
296+
#[derive(Clone, Debug)]
297297
pub struct CrlIssuingDistributionPoint {
298298
/// The CRL's distribution point, containing a sequence of URIs the CRL can be retrieved from.
299299
pub distribution_point: CrlDistributionPoint,
@@ -336,7 +336,7 @@ pub enum CrlScope {
336336
}
337337

338338
/// Parameters used for describing a revoked certificate included in a [`CertificateRevocationList`].
339-
#[derive(Debug)]
339+
#[derive(Clone, Debug)]
340340
pub struct RevokedCertParams {
341341
/// Serial number identifying the revoked certificate.
342342
pub serial_number: SerialNumber,

rcgen/src/csr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
use crate::{DistinguishedName, SanType};
1414

1515
/// A public key, extracted from a CSR
16-
#[derive(Debug, PartialEq, Eq, Hash)]
16+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1717
pub struct PublicKey {
1818
raw: Vec<u8>,
1919
alg: &'static SignatureAlgorithm,
@@ -37,7 +37,7 @@ impl PublicKeyData for PublicKey {
3737
}
3838

3939
/// A certificate signing request (CSR) that can be encoded to PEM or DER.
40-
#[derive(Debug)]
40+
#[derive(Clone, Debug)]
4141
pub struct CertificateSigningRequest {
4242
pub(crate) der: CertificateSigningRequestDer<'static>,
4343
}
@@ -66,7 +66,7 @@ impl From<CertificateSigningRequest> for CertificateSigningRequestDer<'static> {
6666
}
6767

6868
/// Parameters for a certificate signing request
69-
#[derive(Debug)]
69+
#[derive(Clone, Debug)]
7070
pub struct CertificateSigningRequestParams {
7171
/// Parameters for the certificate to be signed.
7272
pub params: CertificateParams,

rcgen/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
#[derive(Debug, PartialEq, Eq)]
3+
#[derive(Clone, Debug, PartialEq, Eq)]
44
#[non_exhaustive]
55
/// The error type of the rcgen crate
66
pub enum Error {
@@ -104,7 +104,7 @@ impl fmt::Display for Error {
104104
impl std::error::Error for Error {}
105105

106106
/// Invalid ASN.1 string type
107-
#[derive(Debug, PartialEq, Eq)]
107+
#[derive(Clone, Debug, PartialEq, Eq)]
108108
#[non_exhaustive]
109109
pub enum InvalidAsn1String {
110110
/// Invalid PrintableString type

rcgen/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ impl DistinguishedName {
430430
/**
431431
Iterator over [`DistinguishedName`] entries
432432
*/
433+
#[derive(Clone)]
433434
pub struct DistinguishedNameIterator<'a> {
434435
distinguished_name: &'a DistinguishedName,
435436
iter: std::slice::Iter<'a, DnType>,

rcgen/src/sign_algo.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ use crate::ring_like::signature::{self, EcdsaSigningAlgorithm, EdDSAParameters,
1010
use crate::Error;
1111

1212
#[cfg(feature = "crypto")]
13+
#[derive(Clone)]
1314
pub(crate) enum SignAlgo {
1415
EcDsa(&'static EcdsaSigningAlgorithm),
1516
EdDsa(&'static EdDSAParameters),
1617
Rsa(&'static dyn RsaEncoding),
1718
}
1819

19-
#[derive(PartialEq, Eq, Hash)]
20+
#[derive(Clone, PartialEq, Eq, Hash)]
2021
pub(crate) enum SignatureAlgorithmParams {
2122
/// Omit the parameters
2223
None,
@@ -30,6 +31,7 @@ pub(crate) enum SignatureAlgorithmParams {
3031
}
3132

3233
/// Signature algorithm type
34+
#[derive(Clone)]
3335
pub struct SignatureAlgorithm {
3436
oids_sign_alg: &'static [&'static [u64]],
3537
#[cfg(feature = "crypto")]

rcgen/tests/openssl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ fn verify_cert_basic(cert: &Certificate) {
4040

4141
// TODO implement Debug manually instead of
4242
// deriving it
43-
#[derive(Debug)]
43+
#[derive(Clone, Debug)]
4444
struct PipeInner([Vec<u8>; 2]);
4545

46-
#[derive(Debug)]
46+
#[derive(Clone, Debug)]
4747
struct PipeEnd {
4848
read_pos: usize,
4949
/// Which end of the pipe

rustls-cert-gen/src/cert.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl PemCertifiedKey {
3737

3838
/// Builder to configure TLS [CertificateParams] to be finalized
3939
/// into either a [Ca] or an [EndEntity].
40-
#[derive(Default)]
40+
#[derive(Clone, Default)]
4141
pub struct CertificateBuilder {
4242
params: CertificateParams,
4343
alg: KeyPairAlgorithm,
@@ -80,6 +80,7 @@ impl CertificateBuilder {
8080
}
8181

8282
/// [CertificateParams] from which an [Ca] [Certificate] can be built
83+
#[derive(Clone)]
8384
pub struct CaBuilder {
8485
params: CertificateParams,
8586
alg: KeyPairAlgorithm,
@@ -161,6 +162,7 @@ impl EndEntity {
161162
}
162163

163164
/// [CertificateParams] from which an [EndEntity] [Certificate] can be built
165+
#[derive(Clone)]
164166
pub struct EndEntityBuilder {
165167
params: CertificateParams,
166168
alg: KeyPairAlgorithm,

0 commit comments

Comments
 (0)