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