From c2a591b45f91462aef13c4d8e0b25580c9d6f992 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 25 Mar 2025 09:21:03 -0600 Subject: [PATCH] ssh-key: add `serde` comment about `PublicKey` Note that "comment" is only carried with the string serialization of `PublicKey`. Fixes #340 --- ssh-key/src/public.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ssh-key/src/public.rs b/ssh-key/src/public.rs index 9a14464a..89b14726 100644 --- a/ssh-key/src/public.rs +++ b/ssh-key/src/public.rs @@ -81,6 +81,12 @@ use crate::PrivateKey; /// The serialization uses a binary encoding with binary formats like bincode /// and CBOR, and the OpenSSH string serialization when used with /// human-readable formats like JSON and TOML. +/// +/// Note that since the `comment` is an artifact on the string serialization of +/// a public key, it will be implicitly dropped when encoding as a binary +/// format. To ensure it's always preserved even when using binary formats, you +/// will first need to convert the [`PublicKey`] to a string using e.g. +/// [`PublicKey::to_openssh`]. #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct PublicKey { /// Key data.