upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-09-17 13:23:22 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-09-17 13:23:22 +0100
commita4bcaf98cc7a00a71f34ed382dc65414eaec5bff (patch)
tree661bcac2b381d232be2488248bc899c48e50fb7e /src/lib
parent12fb184cd1a875704d4f187531aa1638513a3dab (diff)
feat(remote): store successful protocol in config
if another protocol was tried first and failed
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/git/nostr_url.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs
index 6fcc11d..42b0ac9 100644
--- a/src/lib/git/nostr_url.rs
+++ b/src/lib/git/nostr_url.rs
@@ -1,7 +1,7 @@
1use core::fmt; 1use core::fmt;
2use std::{collections::HashSet, str::FromStr}; 2use std::{collections::HashSet, str::FromStr};
3 3
4use anyhow::{anyhow, bail, Context, Result}; 4use anyhow::{anyhow, bail, Context, Error, Result};
5use nostr::nips::nip01::Coordinate; 5use nostr::nips::nip01::Coordinate;
6use nostr_sdk::{PublicKey, Url}; 6use nostr_sdk::{PublicKey, Url};
7 7
@@ -34,6 +34,25 @@ impl fmt::Display for ServerProtocol {
34 } 34 }
35} 35}
36 36
37impl FromStr for ServerProtocol {
38 type Err = Error;
39
40 // Method to convert a string to a ServerProtocol variant
41 fn from_str(s: &str) -> Result<ServerProtocol> {
42 match s {
43 "http" => Ok(ServerProtocol::Http),
44 "https" => Ok(ServerProtocol::Https),
45 "ftp" => Ok(ServerProtocol::Ftp),
46 "ssh" => Ok(ServerProtocol::Ssh),
47 "git" => Ok(ServerProtocol::Git),
48 "filesystem" => Ok(ServerProtocol::Filesystem),
49 "http (unauthenticated)" => Ok(ServerProtocol::UnauthHttp),
50 "https (unauthenticated)" => Ok(ServerProtocol::UnauthHttps),
51 _ => bail!("not listed as a server protocol"),
52 }
53 }
54}
55
37#[derive(Debug, PartialEq)] 56#[derive(Debug, PartialEq)]
38pub struct NostrUrlDecoded { 57pub struct NostrUrlDecoded {
39 pub original_string: String, 58 pub original_string: String,