diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-04 14:40:27 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-04 14:40:27 +0100 |
| commit | 90c53e2dc859b47615ebaa08199b7460615ce3e4 (patch) | |
| tree | 688eebcc5289ca41e08a1d8c4ec25ee1336e932e /src | |
| parent | 771f944af447c202eba045936a36dee71ab797ac (diff) | |
refactor: use FromStr trait for NostrUrlDecoded
as it should have been used in the first place
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/list.rs | 0 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 1 | ||||
| -rw-r--r-- | src/lib/git/nostr_url.rs | 8 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/bin/git_remote_nostr/list.rs | |||
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index 3e08efe..8d67552 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs | |||
| @@ -10,6 +10,7 @@ use std::{ | |||
| 10 | env, | 10 | env, |
| 11 | io::{self, Stdin}, | 11 | io::{self, Stdin}, |
| 12 | path::{Path, PathBuf}, | 12 | path::{Path, PathBuf}, |
| 13 | str::FromStr, | ||
| 13 | }; | 14 | }; |
| 14 | 15 | ||
| 15 | use anyhow::{anyhow, bail, Context, Result}; | 16 | use anyhow::{anyhow, bail, Context, Result}; |
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 { | |||
| 21 | 21 | ||
| 22 | 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"; | 22 | 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"; |
| 23 | 23 | ||
| 24 | impl NostrUrlDecoded { | 24 | impl std::str::FromStr for NostrUrlDecoded { |
| 25 | pub fn from_str(url: &str) -> Result<Self> { | 25 | type Err = anyhow::Error; |
| 26 | |||
| 27 | fn from_str(url: &str) -> Result<Self> { | ||
| 26 | let mut coordinates = HashSet::new(); | 28 | let mut coordinates = HashSet::new(); |
| 27 | let mut protocol = None; | 29 | let mut protocol = None; |
| 28 | let mut user = None; | 30 | let mut user = None; |
| @@ -257,6 +259,8 @@ mod tests { | |||
| 257 | } | 259 | } |
| 258 | 260 | ||
| 259 | mod nostr_git_url_paramemters_from_str { | 261 | mod nostr_git_url_paramemters_from_str { |
| 262 | use std::str::FromStr; | ||
| 263 | |||
| 260 | use super::*; | 264 | use super::*; |
| 261 | 265 | ||
| 262 | fn get_model_coordinate(relays: bool) -> Coordinate { | 266 | fn get_model_coordinate(relays: bool) -> Coordinate { |