use std::fmt;
use std::str::FromStr;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RelayUrl(pub(crate) iroh::RelayUrl);
impl fmt::Display for RelayUrl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl FromStr for RelayUrl {
type Err = iroh::RelayUrlParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
s.parse::<iroh::RelayUrl>().map(Self)
}
}
impl From<iroh::RelayUrl> for RelayUrl {
fn from(url: iroh::RelayUrl) -> Self {
Self(url)
}
}
#[derive(Debug, Clone)]
pub struct SecretKey(pub(crate) iroh::SecretKey);
impl SecretKey {
pub fn from_bytes(bytes: &[u8; 32]) -> Self {
Self(iroh::SecretKey::from_bytes(bytes))
}
pub fn to_bytes(&self) -> [u8; 32] {
self.0.to_bytes()
}
pub fn public(&self) -> iroh::EndpointId {
self.0.public()
}
}
impl From<iroh::SecretKey> for SecretKey {
fn from(key: iroh::SecretKey) -> Self {
Self(key)
}
}