From 686a4301675128fa49979e483cf89966f2a078c6 Mon Sep 17 00:00:00 2001 From: piquel Date: Sun, 22 Nov 2026 13:13:29 +0100 Subject: [PATCH] refactor(common): KeyId and ErrorDescription get their serde conversions from text_conversions! --- crates/common/src/protocol/jwt.rs | 15 +-------------- crates/common/src/protocol/oauth.rs | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/crates/common/src/protocol/jwt.rs b/crates/common/src/protocol/jwt.rs index 256595fec..9ca567b96 100644 --- a/crates/common/src/protocol/jwt.rs +++ b/crates/common/src/protocol/jwt.rs @@ -146,20 +146,7 @@ impl FromStr for KeyId { } } -impl TryFrom for KeyId { - type Error = InvalidKeyId; - /// Validates owned text, as serde reads it. - fn try_from(value: String) -> Result { - value.parse() - } -} - -impl From for String { - /// The identifier unchanged. - fn from(value: KeyId) -> Self { - value.0 - } -} +text_conversions!(KeyId); impl fmt::Display for KeyId { /// Writes the identifier unchanged. diff --git a/crates/common/src/protocol/oauth.rs b/crates/common/src/protocol/oauth.rs index 787914169..e36e117bb 100644 --- a/crates/common/src/protocol/oauth.rs +++ b/crates/common/src/protocol/oauth.rs @@ -419,20 +419,7 @@ impl FromStr for ErrorDescription { } } -impl TryFrom for ErrorDescription { - type Error = InvalidDescription; - /// Same as `parse`. - fn try_from(text: String) -> Result { - text.parse() - } -} - -impl From for String { - /// The description text. - fn from(description: ErrorDescription) -> Self { - description.0 - } -} +text_conversions!(ErrorDescription); impl fmt::Display for ErrorDescription { /// Writes the description.