subscriptions.rs (901B)
1 use crate::timeline::{TimelineId, TimelineKind}; 2 use std::collections::HashMap; 3 use uuid::Uuid; 4 5 #[derive(Debug, Clone)] 6 pub enum SubKind { 7 /// Initial subscription. This is the first time we do a remote subscription 8 /// for a timeline 9 Initial, 10 11 /// One shot requests, we can just close after we receive EOSE 12 OneShot, 13 14 Timeline(TimelineKind), 15 16 /// We are fetching a contact list so that we can use it for our follows 17 /// Filter. 18 // TODO: generalize this to any list? 19 FetchingContactList(TimelineId), 20 } 21 22 /// Subscriptions that need to be tracked at various stages. Sometimes we 23 /// need to do A, then B, then C. Tracking requests at various stages by 24 /// mapping uuid subids to explicit states happens here. 25 #[derive(Default)] 26 pub struct Subscriptions { 27 pub subs: HashMap<String, SubKind>, 28 } 29 30 pub fn new_sub_id() -> String { 31 Uuid::new_v4().to_string() 32 }