From 90c53e2dc859b47615ebaa08199b7460615ce3e4 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 4 Sep 2024 14:40:27 +0100 Subject: refactor: use FromStr trait for NostrUrlDecoded as it should have been used in the first place --- src/lib/git/nostr_url.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs index ce3e973..d1fee2e 100644 --- a/src/lib/git/nostr_url.rs +++ b/src/lib/git/nostr_url.rs @@ -21,8 +21,10 @@ pub struct NostrUrlDecoded { static INCORRECT_NOSTR_URL_FORMAT_ERROR: &str = "incorrect nostr git url format. try nostr://naddr123 or nostr://npub123/my-repo or nostr://ssh/npub123/relay.damus.io/my-repo"; -impl NostrUrlDecoded { - pub fn from_str(url: &str) -> Result { +impl std::str::FromStr for NostrUrlDecoded { + type Err = anyhow::Error; + + fn from_str(url: &str) -> Result { let mut coordinates = HashSet::new(); let mut protocol = None; let mut user = None; @@ -257,6 +259,8 @@ mod tests { } mod nostr_git_url_paramemters_from_str { + use std::str::FromStr; + use super::*; fn get_model_coordinate(relays: bool) -> Coordinate { -- cgit v1.2.3