A better Rust ATProto crate
at main 9.7 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.subscribeRepos 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. 9#[jacquard_derive::lexicon] 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic, 18 bon::Builder 19)] 20#[serde(rename_all = "camelCase")] 21pub struct Account<'a> { 22 /// Indicates that the account has a repository which can be fetched from the host that emitted this event. 23 pub active: bool, 24 #[serde(borrow)] 25 pub did: jacquard_common::types::string::Did<'a>, 26 pub seq: i64, 27 /// If active=false, this optional field indicates a reason for why the account is not active. 28 #[serde(skip_serializing_if = "std::option::Option::is_none")] 29 #[builder(into)] 30 #[serde(borrow)] 31 pub status: Option<jacquard_common::CowStr<'a>>, 32 pub time: jacquard_common::types::string::Datetime, 33} 34 35/// Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. 36#[jacquard_derive::lexicon] 37#[derive( 38 serde::Serialize, 39 serde::Deserialize, 40 Debug, 41 Clone, 42 PartialEq, 43 Eq, 44 jacquard_derive::IntoStatic, 45 bon::Builder 46)] 47#[serde(rename_all = "camelCase")] 48pub struct Commit<'a> { 49 #[serde(borrow)] 50 pub blobs: Vec<jacquard_common::types::cid::CidLink<'a>>, 51 /// CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list. 52 pub blocks: bytes::Bytes, 53 /// Repo commit object CID. 54 #[serde(borrow)] 55 pub commit: jacquard_common::types::cid::CidLink<'a>, 56 #[serde(borrow)] 57 pub ops: Vec<crate::com_atproto::sync::subscribe_repos::RepoOp<'a>>, 58 /// The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose. 59 #[serde(skip_serializing_if = "std::option::Option::is_none")] 60 #[builder(into)] 61 #[serde(borrow)] 62 pub prev_data: Option<jacquard_common::types::cid::CidLink<'a>>, 63 /// DEPRECATED -- unused 64 pub rebase: bool, 65 /// The repo this event comes from. Note that all other message types name this field 'did'. 66 #[serde(borrow)] 67 pub repo: jacquard_common::types::string::Did<'a>, 68 /// The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event. 69 pub rev: jacquard_common::types::string::Tid, 70 /// The stream sequence number of this message. 71 pub seq: i64, 72 /// The rev of the last emitted commit from this repo (if any). 73 pub since: jacquard_common::types::string::Tid, 74 /// Timestamp of when this message was originally broadcast. 75 pub time: jacquard_common::types::string::Datetime, 76 /// DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data. 77 pub too_big: bool, 78} 79 80/// Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. 81#[jacquard_derive::lexicon] 82#[derive( 83 serde::Serialize, 84 serde::Deserialize, 85 Debug, 86 Clone, 87 PartialEq, 88 Eq, 89 jacquard_derive::IntoStatic, 90 bon::Builder 91)] 92#[serde(rename_all = "camelCase")] 93pub struct Identity<'a> { 94 #[serde(borrow)] 95 pub did: jacquard_common::types::string::Did<'a>, 96 /// The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details. 97 #[serde(skip_serializing_if = "std::option::Option::is_none")] 98 #[builder(into)] 99 #[serde(borrow)] 100 pub handle: Option<jacquard_common::types::string::Handle<'a>>, 101 pub seq: i64, 102 pub time: jacquard_common::types::string::Datetime, 103} 104 105#[jacquard_derive::lexicon] 106#[derive( 107 serde::Serialize, 108 serde::Deserialize, 109 Debug, 110 Clone, 111 PartialEq, 112 Eq, 113 jacquard_derive::IntoStatic, 114 Default 115)] 116#[serde(rename_all = "camelCase")] 117pub struct Info<'a> { 118 #[serde(skip_serializing_if = "std::option::Option::is_none")] 119 #[serde(borrow)] 120 pub message: std::option::Option<jacquard_common::CowStr<'a>>, 121 #[serde(borrow)] 122 pub name: jacquard_common::CowStr<'a>, 123} 124 125#[derive( 126 serde::Serialize, 127 serde::Deserialize, 128 Debug, 129 Clone, 130 PartialEq, 131 Eq, 132 bon::Builder, 133 jacquard_derive::IntoStatic 134)] 135#[builder(start_fn = new)] 136#[serde(rename_all = "camelCase")] 137pub struct SubscribeRepos { 138 #[serde(skip_serializing_if = "std::option::Option::is_none")] 139 pub cursor: std::option::Option<i64>, 140} 141 142#[jacquard_derive::open_union] 143#[derive( 144 serde::Serialize, 145 serde::Deserialize, 146 Debug, 147 Clone, 148 PartialEq, 149 Eq, 150 jacquard_derive::IntoStatic 151)] 152#[serde(tag = "$type")] 153#[serde(bound(deserialize = "'de: 'a"))] 154pub enum SubscribeReposMessage<'a> { 155 #[serde(rename = "#commit")] 156 Commit(Box<jacquard_common::types::value::Data<'a>>), 157 #[serde(rename = "#sync")] 158 Sync(Box<jacquard_common::types::value::Data<'a>>), 159 #[serde(rename = "#identity")] 160 Identity(Box<jacquard_common::types::value::Data<'a>>), 161 #[serde(rename = "#account")] 162 Account(Box<jacquard_common::types::value::Data<'a>>), 163 #[serde(rename = "#info")] 164 Info(Box<jacquard_common::types::value::Data<'a>>), 165} 166 167#[jacquard_derive::open_union] 168#[derive( 169 serde::Serialize, 170 serde::Deserialize, 171 Debug, 172 Clone, 173 PartialEq, 174 Eq, 175 thiserror::Error, 176 miette::Diagnostic, 177 jacquard_derive::IntoStatic 178)] 179#[serde(tag = "error", content = "message")] 180#[serde(bound(deserialize = "'de: 'a"))] 181pub enum SubscribeReposError<'a> { 182 #[serde(rename = "FutureCursor")] 183 FutureCursor(std::option::Option<String>), 184 /// If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection. 185 #[serde(rename = "ConsumerTooSlow")] 186 ConsumerTooSlow(std::option::Option<String>), 187} 188 189impl std::fmt::Display for SubscribeReposError<'_> { 190 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 191 match self { 192 Self::FutureCursor(msg) => { 193 write!(f, "FutureCursor")?; 194 if let Some(msg) = msg { 195 write!(f, ": {}", msg)?; 196 } 197 Ok(()) 198 } 199 Self::ConsumerTooSlow(msg) => { 200 write!(f, "ConsumerTooSlow")?; 201 if let Some(msg) = msg { 202 write!(f, ": {}", msg)?; 203 } 204 Ok(()) 205 } 206 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 207 } 208 } 209} 210 211/// A repo operation, ie a mutation of a single record. 212#[jacquard_derive::lexicon] 213#[derive( 214 serde::Serialize, 215 serde::Deserialize, 216 Debug, 217 Clone, 218 PartialEq, 219 Eq, 220 jacquard_derive::IntoStatic, 221 bon::Builder 222)] 223#[serde(rename_all = "camelCase")] 224pub struct RepoOp<'a> { 225 #[serde(borrow)] 226 #[builder(into)] 227 pub action: jacquard_common::CowStr<'a>, 228 /// For creates and updates, the new record CID. For deletions, null. 229 #[serde(borrow)] 230 pub cid: jacquard_common::types::cid::CidLink<'a>, 231 #[serde(borrow)] 232 #[builder(into)] 233 pub path: jacquard_common::CowStr<'a>, 234 /// For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined. 235 #[serde(skip_serializing_if = "std::option::Option::is_none")] 236 #[builder(into)] 237 #[serde(borrow)] 238 pub prev: Option<jacquard_common::types::cid::CidLink<'a>>, 239} 240 241/// Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. 242#[jacquard_derive::lexicon] 243#[derive( 244 serde::Serialize, 245 serde::Deserialize, 246 Debug, 247 Clone, 248 PartialEq, 249 Eq, 250 jacquard_derive::IntoStatic, 251 bon::Builder 252)] 253#[serde(rename_all = "camelCase")] 254pub struct Sync<'a> { 255 /// CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. 256 pub blocks: bytes::Bytes, 257 /// The account this repo event corresponds to. Must match that in the commit object. 258 #[serde(borrow)] 259 pub did: jacquard_common::types::string::Did<'a>, 260 /// The rev of the commit. This value must match that in the commit object. 261 #[serde(borrow)] 262 #[builder(into)] 263 pub rev: jacquard_common::CowStr<'a>, 264 /// The stream sequence number of this message. 265 pub seq: i64, 266 /// Timestamp of when this message was originally broadcast. 267 pub time: jacquard_common::types::string::Datetime, 268}