~kmaasrud/pimalaya-webfinger

67da11092609e86c55712717fa8b087110f030a4 — Knut Magnus Aasrud 10 months ago e46b565
perf: parse Uris from string slices
1 files changed, 3 insertions(+), 11 deletions(-)

M src/uri.rs
M src/uri.rs => src/uri.rs +3 -11
@@ 12,10 12,10 @@ pub struct Uri {
    path: PathBuf,
}

impl TryFrom<String> for Uri {
impl TryFrom<&str> for Uri {
    type Error = UriValidationError;

    fn try_from(s: String) -> Result<Self, Self::Error> {
    fn try_from(s: &str) -> Result<Self, Self::Error> {
        let mut parts = s.split("://");

        let scheme = parts


@@ 45,14 45,6 @@ impl TryFrom<String> for Uri {
    }
}

impl TryFrom<&str> for Uri {
    type Error = UriValidationError;

    fn try_from(s: &str) -> Result<Self, Self::Error> {
        Uri::try_from(s.to_string())
    }
}

impl Display for Uri {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(


@@ 70,7 62,7 @@ impl<'de> Deserialize<'de> for Uri {
    where
        D: serde::Deserializer<'de>,
    {
        Uri::try_from(String::deserialize(deserializer)?).map_err(serde::de::Error::custom)
        Uri::try_from(String::deserialize(deserializer)?.as_ref()).map_err(serde::de::Error::custom)
    }
}