use crate::event::{Coordinate, Kind};
use crate::key::PublicKey;
use crate::types::RelayUrl;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Nip19Coordinate {
pub coordinate: Coordinate,
pub relays: Vec<RelayUrl>,
}
impl Nip19Coordinate {
#[must_use]
pub fn new(
identifier: impl Into<String>,
author: PublicKey,
kind: Kind,
relays: impl IntoIterator<Item = RelayUrl>,
) -> Self {
Self {
coordinate: Coordinate::new(kind, author, identifier),
relays: relays.into_iter().collect(),
}
}
#[must_use]
pub fn from_coordinate(
coordinate: Coordinate,
relays: impl IntoIterator<Item = RelayUrl>,
) -> Self {
Self {
coordinate,
relays: relays.into_iter().collect(),
}
}
#[must_use]
pub const fn kind(&self) -> Kind {
self.coordinate.kind
}
#[must_use]
pub const fn author(&self) -> &PublicKey {
&self.coordinate.author
}
#[must_use]
pub fn identifier(&self) -> &str {
&self.coordinate.identifier
}
}