nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

info.rs (1531B)


      1 //! Relay metadata using NIP-11
      2 /// Relay Info
      3 use crate::config;
      4 use serde::{Deserialize, Serialize};
      5 
      6 pub const CARGO_PKG_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
      7 
      8 #[derive(Debug, Serialize, Deserialize)]
      9 #[allow(unused)]
     10 pub struct RelayInfo {
     11     #[serde(skip_serializing_if = "Option::is_none")]
     12     pub id: Option<String>,
     13     #[serde(skip_serializing_if = "Option::is_none")]
     14     pub name: Option<String>,
     15     #[serde(skip_serializing_if = "Option::is_none")]
     16     pub description: Option<String>,
     17     #[serde(skip_serializing_if = "Option::is_none")]
     18     pub pubkey: Option<String>,
     19     #[serde(skip_serializing_if = "Option::is_none")]
     20     pub contact: Option<String>,
     21     #[serde(skip_serializing_if = "Option::is_none")]
     22     pub supported_nips: Option<Vec<i64>>,
     23     #[serde(skip_serializing_if = "Option::is_none")]
     24     pub software: Option<String>,
     25     #[serde(skip_serializing_if = "Option::is_none")]
     26     pub version: Option<String>,
     27 }
     28 
     29 /// Convert an Info configuration into public Relay Info
     30 impl From<config::Info> for RelayInfo {
     31     fn from(i: config::Info) -> Self {
     32         RelayInfo {
     33             id: i.relay_url,
     34             name: i.name,
     35             description: i.description,
     36             pubkey: i.pubkey,
     37             contact: i.contact,
     38             supported_nips: Some(vec![1, 2, 9, 11, 12, 15, 16, 22, 26]),
     39             software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()),
     40             version: CARGO_PKG_VERSION.map(|x| x.to_owned()),
     41         }
     42     }
     43 }