feat: out-of-box experience (#2)

Reviewed-on: https://git.reya.su/reya/signed/pulls/2
This commit was merged in pull request #2.
This commit is contained in:
2026-08-25 13:23:07 +00:00
parent 7249a323f8
commit dacfd49cdf
180 changed files with 16763 additions and 1042 deletions
+9 -40
View File
@@ -1,44 +1,13 @@
use std::fmt;
use std::str::FromStr;
use nostr::prelude::*;
/// Address of a NIP-34 repository announcement: `30617:<owner-pubkey>:<repo-id>`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RepoAddr {
pub owner: PublicKey,
pub id: String,
}
impl RepoAddr {
pub fn new(owner: PublicKey, id: impl Into<String>) -> Self {
Self {
owner,
id: id.into(),
}
}
/// The NIP-33 coordinate for the announcement event (`a` tag value).
pub fn coordinate(&self) -> Coordinate {
Coordinate::new(Kind::GitRepoAnnouncement, self.owner).identifier(self.id.clone())
}
}
impl fmt::Display for RepoAddr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.coordinate())
}
}
impl FromStr for RepoAddr {
type Err = nostr::error::Error;
/// Parse from `<kind>:<pubkey>:<d-tag>`, `naddr1...` bech32 or `nostr:naddr1...` URI.
fn from_str(s: &str) -> Result<Self, Self::Err> {
let coordinate = Coordinate::parse(s)?;
Ok(Self {
owner: coordinate.public_key,
id: coordinate.identifier,
})
}
///
/// The Rust Nostr SDK's [`Coordinate`] already provides parsing, formatting
/// and hashing for this; the alias keeps the repository-specific vocabulary
/// while reusing the SDK type.
pub type RepoAddr = Coordinate;
/// Build the address of a NIP-34 repository announcement.
pub fn repo_addr(owner: PublicKey, id: impl Into<String>) -> RepoAddr {
Coordinate::new(Kind::GitRepoAnnouncement, owner).identifier(id)
}