From 5e403d3dd5ed30db9086253228aaf4992c00dfcf Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Wed, 7 Feb 2024 15:02:23 -0500 Subject: [PATCH] docs; further refinement of no-clone advice * Fix a markdown rendering typo * Mention `clone_key` --- README.md | 7 ++++--- src/lib.rs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c96958e..57273d1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 4d9d754..5832336 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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)]