Skip to content

Commit

Permalink
docs; further refinement of no-clone advice
Browse files Browse the repository at this point in the history
* Fix a markdown rendering typo
* Mention `clone_key`
  • Loading branch information
cpu committed Feb 7, 2024
1 parent 204a83d commit 5e403d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ the [rcgen](https://docs.rs/rcgen) crate can be used to create new certificates
This crate intentionally **does not** implement `Clone` on private key types in
order to minimize the exposure of private key data in memory.

Since these types are immutable, if you find you're self wanting to clone them
it may be better to consider wrapping the `PrivateKeyDer<'_>` in a [`Rc`]` or
[`Arc`].
If you want to extend the lifetime of a `PrivateKeyDer<'_>`, consider [`PrivateKeyDer::clone_key()`].
Alternatively since these types are immutable, consider wrapping the `PrivateKeyDer<'_>` in a [`Rc`]
or an [`Arc`].

[`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html
[`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html
[`PrivateKeyDer::clone_key()`]: https://docs.rs/rustls-pki-types/latest/rustls_pki_types/enum.PrivateKeyDer.html#method.clone_key
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
//! This crate intentionally **does not** implement `Clone` on private key types in
//! order to minimize the exposure of private key data in memory.
//!
//! Since these types are immutable, if you find you're self wanting to clone them
//! it may be better to consider wrapping the `PrivateKeyDer<'_>` in a [`Rc`]` or
//! [`Arc`].
//! If you want to extend the lifetime of a `PrivateKeyDer<'_>`, consider [`PrivateKeyDer::clone_key()`].
//! Alternatively since these types are immutable, consider wrapping the `PrivateKeyDer<'_>` in a [`Rc`]
//! or an [`Arc`].
//!
//! [`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html
//! [`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html
//! [`PrivateKeyDer::clone_key()`]: https://docs.rs/rustls-pki-types/latest/rustls_pki_types/enum.PrivateKeyDer.html#method.clone_key
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(unreachable_pub, clippy::use_self)]
Expand Down

0 comments on commit 5e403d3

Please sign in to comment.