lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

query.rs (1586B)


      1 use crate::filter::RadrootsNostrNdbFilterSpec;
      2 
      3 #[derive(Debug, Clone, Eq, PartialEq)]
      4 pub struct RadrootsNostrNdbQuerySpec {
      5     filters: Vec<RadrootsNostrNdbFilterSpec>,
      6     max_results: u32,
      7 }
      8 
      9 impl RadrootsNostrNdbQuerySpec {
     10     pub fn new(filters: Vec<RadrootsNostrNdbFilterSpec>, max_results: u32) -> Self {
     11         Self {
     12             filters,
     13             max_results: max_results.max(1),
     14         }
     15     }
     16 
     17     pub fn single(filter: RadrootsNostrNdbFilterSpec, max_results: u32) -> Self {
     18         Self::new(vec![filter], max_results)
     19     }
     20 
     21     pub fn text_notes(limit: Option<u64>, since_unix: Option<u64>, max_results: u32) -> Self {
     22         Self::single(
     23             RadrootsNostrNdbFilterSpec::text_notes(limit, since_unix),
     24             max_results,
     25         )
     26     }
     27 
     28     pub fn filters(&self) -> &[RadrootsNostrNdbFilterSpec] {
     29         &self.filters
     30     }
     31 
     32     pub fn max_results(&self) -> u32 {
     33         self.max_results
     34     }
     35 }
     36 
     37 #[derive(Debug, Clone, Eq, PartialEq)]
     38 pub struct RadrootsNostrNdbNote {
     39     pub note_key: u64,
     40     pub id_hex: String,
     41     pub author_hex: String,
     42     pub kind: u32,
     43     pub created_at_unix: u64,
     44     pub content: String,
     45     pub json: String,
     46 }
     47 
     48 #[derive(Debug, Clone, Eq, PartialEq)]
     49 pub struct RadrootsNostrNdbProfile {
     50     pub profile_key: Option<u64>,
     51     pub pubkey_hex: String,
     52     pub name: Option<String>,
     53     pub display_name: Option<String>,
     54     pub about: Option<String>,
     55     pub picture: Option<String>,
     56     pub banner: Option<String>,
     57     pub website: Option<String>,
     58     pub nip05: Option<String>,
     59     pub lud16: Option<String>,
     60 }