Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
node: Serialize and deserialize ipv6 addresses in square brackets
Merged Defelo opened 1 month ago

Completely forgot about serialization in 5ba439004894d9a6e62bc439a8530e4981f7912d. This should fix parsing of IPv6 addresses for example in config.json

1 file changed +15 -1 addce859 a2e72b48
modified 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<String> for Address {
+
    type Error = <Self as FromStr>::Err;
+

+
    fn try_from(value: String) -> Result<Self, Self::Error> {
+
        value.parse()
+
    }
+
}
+

+
impl From<Address> for String {
+
    fn from(value: Address) -> Self {
+
        value.to_string()
+
    }
+
}
+

impl FromStr for Address {
    type Err = AddrParseError;