Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

clean up dervive traits, specific cursor name

the derives came in from base64 in tangled#7, whic was removed.

the cursor is a composite, but we might have other composite cursors that are different -- renaming this one to reflect its specific purpose.

authored by bad-example.com and committed by tangled.org 87fcfd54 d4bbd7bb

+19 -21
+2 -2
constellation/src/lib.rs
··· 22 DeleteAccount(Did), 23 } 24 25 - #[derive(Debug, Hash, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] 26 pub struct Did(pub String); 27 28 impl<T: Into<String>> From<T> for Did { ··· 31 } 32 } 33 34 - #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord)] 35 pub struct RecordId { 36 pub did: Did, 37 pub collection: String,
··· 22 DeleteAccount(Did), 23 } 24 25 + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)] 26 pub struct Did(pub String); 27 28 impl<T: Into<String>> From<T> for Did { ··· 31 } 32 } 33 34 + #[derive(Debug, PartialEq, Serialize, Deserialize)] 35 pub struct RecordId { 36 pub did: Did, 37 pub collection: String,
+1 -1
constellation/src/server/mod.rs
··· 709 #[serde(default = "get_default_cursor_limit")] 710 limit: u64, 711 } 712 - #[derive(Debug, Serialize, Clone)] 713 struct ManyToManyItem { 714 link: RecordId, 715 subject: String,
··· 709 #[serde(default = "get_default_cursor_limit")] 710 limit: u64, 711 } 712 + #[derive(Debug, Serialize)] 713 struct ManyToManyItem { 714 link: RecordId, 715 subject: String,
+7 -7
constellation/src/storage/mem_store.rs
··· 1 use super::{ 2 - LinkReader, LinkStorage, Order, PagedAppendingCollection, PagedOrderedCollection, StorageStats, 3 }; 4 - use crate::storage::CompositeCursor; 5 use crate::{ActionableEvent, CountsByCount, Did, RecordId}; 6 7 use anyhow::{anyhow, Result}; ··· 264 let f = f 265 .parse::<u64>() 266 .map_err(|e| anyhow!("invalid cursor.1: {e}"))?; 267 - Some(CompositeCursor { 268 - backward: b, 269 - forward: f, 270 }) 271 } 272 None => None, ··· 287 .iter() 288 .enumerate() 289 .filter_map(|(i, opt)| opt.as_ref().map(|v| (i, v))) 290 - .skip_while(|(linker_idx, _)| cursor.is_some_and(|c| *linker_idx < c.backward as usize)) 291 .filter(|(_, (did, _))| filter_dids.is_empty() || filter_dids.contains(did)) 292 { 293 let Some(links) = data.links.get(did).and_then(|m| { ··· 308 }) 309 .skip_while(|(link_idx, _)| { 310 cursor.is_some_and(|c| { 311 - linker_idx == c.backward as usize && *link_idx <= c.forward as usize 312 }) 313 }) 314 .take(limit as usize + 1 - items.len())
··· 1 use super::{ 2 + LinkReader, LinkStorage, ManyToManyCursor, Order, PagedAppendingCollection, 3 + PagedOrderedCollection, StorageStats, 4 }; 5 use crate::{ActionableEvent, CountsByCount, Did, RecordId}; 6 7 use anyhow::{anyhow, Result}; ··· 264 let f = f 265 .parse::<u64>() 266 .map_err(|e| anyhow!("invalid cursor.1: {e}"))?; 267 + Some(ManyToManyCursor { 268 + backlink: b, 269 + forward_link: f, 270 }) 271 } 272 None => None, ··· 287 .iter() 288 .enumerate() 289 .filter_map(|(i, opt)| opt.as_ref().map(|v| (i, v))) 290 + .skip_while(|(linker_idx, _)| cursor.is_some_and(|c| *linker_idx < c.backlink as usize)) 291 .filter(|(_, (did, _))| filter_dids.is_empty() || filter_dids.contains(did)) 292 { 293 let Some(links) = data.links.get(did).and_then(|m| { ··· 308 }) 309 .skip_while(|(link_idx, _)| { 310 cursor.is_some_and(|c| { 311 + linker_idx == c.backlink as usize && *link_idx <= c.forward_link as usize 312 }) 313 }) 314 .take(limit as usize + 1 - items.len())
+3 -4
constellation/src/storage/mod.rs
··· 39 } 40 } 41 42 - // get-many-to-many composite cursor 43 #[derive(Copy, Clone, Debug)] 44 - struct CompositeCursor { 45 - backward: u64, 46 - forward: u64, 47 } 48 49 /// A paged collection whose keys are sorted instead of indexed
··· 39 } 40 } 41 42 #[derive(Copy, Clone, Debug)] 43 + struct ManyToManyCursor { 44 + backlink: u64, 45 + forward_link: u64, 46 } 47 48 /// A paged collection whose keys are sorted instead of indexed
+6 -7
constellation/src/storage/rocks_store.rs
··· 1 use super::{ 2 - ActionableEvent, LinkReader, LinkStorage, Order, PagedAppendingCollection, 3 PagedOrderedCollection, StorageStats, 4 }; 5 - use crate::storage::CompositeCursor; 6 use crate::{CountsByCount, Did, RecordId}; 7 8 use anyhow::{anyhow, bail, Result}; ··· 1165 let f = f 1166 .parse::<u64>() 1167 .map_err(|e| anyhow!("invalid cursor.1: {e}"))?; 1168 - Some(CompositeCursor { 1169 - backward: b, 1170 - forward: f, 1171 }) 1172 } 1173 None => None, ··· 1202 // iterate backwards (who linked to the target?) 1203 for (linker_idx, (did_id, rkey)) in 1204 linkers.0.iter().enumerate().skip_while(|(linker_idx, _)| { 1205 - cursor.is_some_and(|c| *linker_idx < c.backward as usize) 1206 }) 1207 { 1208 if did_id.is_empty() ··· 1233 }) 1234 .skip_while(|(link_idx, _)| { 1235 cursor.is_some_and(|c| { 1236 - linker_idx == c.backward as usize && *link_idx <= c.forward as usize 1237 }) 1238 }) 1239 .take(limit as usize + 1 - items.len())
··· 1 use super::{ 2 + ActionableEvent, LinkReader, LinkStorage, ManyToManyCursor, Order, PagedAppendingCollection, 3 PagedOrderedCollection, StorageStats, 4 }; 5 use crate::{CountsByCount, Did, RecordId}; 6 7 use anyhow::{anyhow, bail, Result}; ··· 1164 let f = f 1165 .parse::<u64>() 1166 .map_err(|e| anyhow!("invalid cursor.1: {e}"))?; 1167 + Some(ManyToManyCursor { 1168 + backlink: b, 1169 + forward_link: f, 1170 }) 1171 } 1172 None => None, ··· 1201 // iterate backwards (who linked to the target?) 1202 for (linker_idx, (did_id, rkey)) in 1203 linkers.0.iter().enumerate().skip_while(|(linker_idx, _)| { 1204 + cursor.is_some_and(|c| *linker_idx < c.backlink as usize) 1205 }) 1206 { 1207 if did_id.is_empty() ··· 1232 }) 1233 .skip_while(|(link_idx, _)| { 1234 cursor.is_some_and(|c| { 1235 + linker_idx == c.backlink as usize && *link_idx <= c.forward_link as usize 1236 }) 1237 }) 1238 .take(limit as usize + 1 - items.len())