From a2e72b48e79d090d33f6c13c485239947de0522e Mon Sep 17 00:00:00 2001 From: Defelo Date: Wed, 18 Mar 2026 20:59:01 +0100 Subject: [PATCH] node: Serialize and deserialize ipv6 addresses in square brackets --- crates/radicle/src/node.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/radicle/src/node.rs b/crates/radicle/src/node.rs index 4493b0fa..7500c42b 100644 --- a/crates/radicle/src/node.rs +++ b/crates/radicle/src/node.rs @@ -427,6 +427,7 @@ impl TryFrom<&sqlite::Value> for Alias { #[derive(Clone, Eq, PartialEq, Debug, Hash, From, Wrapper, WrapperMut, Serialize, Deserialize)] #[wrapper(Deref)] #[wrapper_mut(DerefMut)] +#[serde(try_from = "String", into = "String")] #[cfg_attr( feature = "schemars", derive(schemars::JsonSchema), @@ -436,7 +437,6 @@ impl TryFrom<&sqlite::Value> for Alias { ") )] pub struct Address( - #[serde(with = "crate::serde_ext::string")] #[cfg_attr(feature = "schemars", schemars( with = "String", regex(pattern = r"^.+:((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$"), @@ -526,6 +526,20 @@ impl Display for Address { } } +impl TryFrom for Address { + type Error = ::Err; + + fn try_from(value: String) -> Result { + value.parse() + } +} + +impl From
for String { + fn from(value: Address) -> Self { + value.to_string() + } +} + impl FromStr for Address { type Err = AddrParseError;