at main 59 lines 1.6 kB view raw
1use jacquard::{ 2 CowStr, IntoStatic, XrpcRequest, 3 types::{ 4 did::Did, 5 nsid::Nsid, 6 string::{RecordKey, Rkey}, 7 }, 8}; 9use serde::{Deserialize, Serialize}; 10 11const DEFAULT_CURSOR_LIMIT: u64 = 16; 12 13fn get_default_cursor_limit() -> u64 { 14 DEFAULT_CURSOR_LIMIT 15} 16 17#[derive(Clone, Deserialize, Serialize, XrpcRequest, IntoStatic)] 18#[xrpc( 19 nsid = "blue.microcosm.links.getBacklinks", 20 method = Query, 21 output = GetBacklinksResponse, 22)] 23pub struct GetBacklinksQuery<'a> { 24 /// The link target 25 /// 26 /// can be an AT-URI, plain DID, or regular URI 27 pub subject: jacquard::types::uri::Uri<'a>, 28 /// Filter links only from this link source 29 /// 30 /// eg.: `app.bsky.feed.like:subject.uri` 31 pub source: CowStr<'a>, 32 #[serde(borrow)] 33 pub cursor: Option<CowStr<'a>>, 34 /// Filter links only from these DIDs 35 /// 36 /// include multiple times to filter by multiple source DIDs 37 #[serde(default)] 38 pub did: Vec<Did<'a>>, 39 /// Set the max number of links to return per page of results 40 #[serde(default = "get_default_cursor_limit")] 41 pub limit: u64, 42 // TODO: allow reverse (er, forward) order as well 43} 44#[derive(Deserialize, Serialize, IntoStatic)] 45pub struct GetBacklinksResponse<'a> { 46 pub total: u64, 47 #[serde(borrow)] 48 pub records: Vec<RecordId<'a>>, 49 pub cursor: Option<CowStr<'a>>, 50} 51 52#[derive(Debug, PartialEq, Serialize, Deserialize, IntoStatic)] 53pub struct RecordId<'a> { 54 #[serde(borrow)] 55 pub did: Did<'a>, 56 pub collection: Nsid<'a>, 57 pub rkey: RecordKey<Rkey<'a>>, 58} 59