mod.rs (697B)
1 use nostrdb::{Filter, Ndb, Subscription}; 2 3 mod thread_sub; 4 mod timeline_sub; 5 6 pub use thread_sub::ThreadSubs; 7 pub use timeline_sub::TimelineSub; 8 9 pub fn ndb_sub(ndb: &Ndb, filter: &[Filter], id: impl std::fmt::Debug) -> Option<Subscription> { 10 match ndb.subscribe(filter) { 11 Ok(s) => Some(s), 12 Err(e) => { 13 tracing::error!("Failed to get subscription for {:?}: {e}", id); 14 None 15 } 16 } 17 } 18 19 pub fn ndb_unsub(ndb: &mut Ndb, sub: Subscription, id: impl std::fmt::Debug) -> bool { 20 match ndb.unsubscribe(sub) { 21 Ok(_) => true, 22 Err(e) => { 23 tracing::error!("Failed to unsub {:?}: {e}", id); 24 false 25 } 26 } 27 }