A better Rust ATProto crate
at oauth 13 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(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 11#[serde(rename_all = "camelCase")] 12pub struct Account<'a> { 13 ///Indicates that the account has a repository which can be fetched from the host that emitted this event. 14 pub active: bool, 15 #[serde(borrow)] 16 pub did: jacquard_common::types::string::Did<'a>, 17 pub seq: i64, 18 ///If active=false, this optional field indicates a reason for why the account is not active. 19 #[serde(skip_serializing_if = "std::option::Option::is_none")] 20 #[serde(borrow)] 21 pub status: std::option::Option<jacquard_common::CowStr<'a>>, 22 pub time: jacquard_common::types::string::Datetime, 23} 24 25impl jacquard_common::IntoStatic for Account<'_> { 26 type Output = Account<'static>; 27 fn into_static(self) -> Self::Output { 28 Account { 29 active: self.active.into_static(), 30 did: self.did.into_static(), 31 seq: self.seq.into_static(), 32 status: self.status.into_static(), 33 time: self.time.into_static(), 34 extra_data: self.extra_data.into_static(), 35 } 36 } 37} 38 39///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. 40#[jacquard_derive::lexicon] 41#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 42#[serde(rename_all = "camelCase")] 43pub struct Commit<'a> { 44 #[serde(borrow)] 45 pub blobs: Vec<jacquard_common::types::cid::CidLink<'a>>, 46 ///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. 47 pub blocks: bytes::Bytes, 48 ///Repo commit object CID. 49 #[serde(borrow)] 50 pub commit: jacquard_common::types::cid::CidLink<'a>, 51 #[serde(borrow)] 52 pub ops: Vec<crate::com_atproto::sync::subscribe_repos::RepoOp<'a>>, 53 ///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. 54 #[serde(skip_serializing_if = "std::option::Option::is_none")] 55 #[serde(borrow)] 56 pub prev_data: std::option::Option<jacquard_common::types::cid::CidLink<'a>>, 57 ///DEPRECATED -- unused 58 pub rebase: bool, 59 ///The repo this event comes from. Note that all other message types name this field 'did'. 60 #[serde(borrow)] 61 pub repo: jacquard_common::types::string::Did<'a>, 62 ///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. 63 pub rev: jacquard_common::types::string::Tid, 64 ///The stream sequence number of this message. 65 pub seq: i64, 66 ///The rev of the last emitted commit from this repo (if any). 67 pub since: jacquard_common::types::string::Tid, 68 ///Timestamp of when this message was originally broadcast. 69 pub time: jacquard_common::types::string::Datetime, 70 ///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. 71 pub too_big: bool, 72} 73 74impl jacquard_common::IntoStatic for Commit<'_> { 75 type Output = Commit<'static>; 76 fn into_static(self) -> Self::Output { 77 Commit { 78 blobs: self.blobs.into_static(), 79 blocks: self.blocks.into_static(), 80 commit: self.commit.into_static(), 81 ops: self.ops.into_static(), 82 prev_data: self.prev_data.into_static(), 83 rebase: self.rebase.into_static(), 84 repo: self.repo.into_static(), 85 rev: self.rev.into_static(), 86 seq: self.seq.into_static(), 87 since: self.since.into_static(), 88 time: self.time.into_static(), 89 too_big: self.too_big.into_static(), 90 extra_data: self.extra_data.into_static(), 91 } 92 } 93} 94 95///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. 96#[jacquard_derive::lexicon] 97#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 98#[serde(rename_all = "camelCase")] 99pub struct Identity<'a> { 100 #[serde(borrow)] 101 pub did: jacquard_common::types::string::Did<'a>, 102 ///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. 103 #[serde(skip_serializing_if = "std::option::Option::is_none")] 104 #[serde(borrow)] 105 pub handle: std::option::Option<jacquard_common::types::string::Handle<'a>>, 106 pub seq: i64, 107 pub time: jacquard_common::types::string::Datetime, 108} 109 110impl jacquard_common::IntoStatic for Identity<'_> { 111 type Output = Identity<'static>; 112 fn into_static(self) -> Self::Output { 113 Identity { 114 did: self.did.into_static(), 115 handle: self.handle.into_static(), 116 seq: self.seq.into_static(), 117 time: self.time.into_static(), 118 extra_data: self.extra_data.into_static(), 119 } 120 } 121} 122 123#[jacquard_derive::lexicon] 124#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 125#[serde(rename_all = "camelCase")] 126pub struct Info<'a> { 127 #[serde(skip_serializing_if = "std::option::Option::is_none")] 128 #[serde(borrow)] 129 pub message: std::option::Option<jacquard_common::CowStr<'a>>, 130 #[serde(borrow)] 131 pub name: jacquard_common::CowStr<'a>, 132} 133 134impl jacquard_common::IntoStatic for Info<'_> { 135 type Output = Info<'static>; 136 fn into_static(self) -> Self::Output { 137 Info { 138 message: self.message.into_static(), 139 name: self.name.into_static(), 140 extra_data: self.extra_data.into_static(), 141 } 142 } 143} 144 145#[derive( 146 serde::Serialize, 147 serde::Deserialize, 148 Debug, 149 Clone, 150 PartialEq, 151 Eq, 152 bon::Builder 153)] 154#[builder(start_fn = new)] 155#[serde(rename_all = "camelCase")] 156pub struct SubscribeRepos { 157 #[serde(skip_serializing_if = "std::option::Option::is_none")] 158 pub cursor: std::option::Option<i64>, 159} 160 161impl jacquard_common::IntoStatic for SubscribeRepos { 162 type Output = SubscribeRepos; 163 fn into_static(self) -> Self::Output { 164 self 165 } 166} 167 168#[jacquard_derive::open_union] 169#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 170#[serde(tag = "$type")] 171#[serde(bound(deserialize = "'de: 'a"))] 172pub enum SubscribeReposMessage<'a> { 173 #[serde(rename = "#commit")] 174 Commit(Box<jacquard_common::types::value::Data<'a>>), 175 #[serde(rename = "#sync")] 176 Sync(Box<jacquard_common::types::value::Data<'a>>), 177 #[serde(rename = "#identity")] 178 Identity(Box<jacquard_common::types::value::Data<'a>>), 179 #[serde(rename = "#account")] 180 Account(Box<jacquard_common::types::value::Data<'a>>), 181 #[serde(rename = "#info")] 182 Info(Box<jacquard_common::types::value::Data<'a>>), 183} 184 185impl jacquard_common::IntoStatic for SubscribeReposMessage<'_> { 186 type Output = SubscribeReposMessage<'static>; 187 fn into_static(self) -> Self::Output { 188 match self { 189 SubscribeReposMessage::Commit(v) => { 190 SubscribeReposMessage::Commit(v.into_static()) 191 } 192 SubscribeReposMessage::Sync(v) => { 193 SubscribeReposMessage::Sync(v.into_static()) 194 } 195 SubscribeReposMessage::Identity(v) => { 196 SubscribeReposMessage::Identity(v.into_static()) 197 } 198 SubscribeReposMessage::Account(v) => { 199 SubscribeReposMessage::Account(v.into_static()) 200 } 201 SubscribeReposMessage::Info(v) => { 202 SubscribeReposMessage::Info(v.into_static()) 203 } 204 SubscribeReposMessage::Unknown(v) => { 205 SubscribeReposMessage::Unknown(v.into_static()) 206 } 207 } 208 } 209} 210 211#[jacquard_derive::open_union] 212#[derive( 213 serde::Serialize, 214 serde::Deserialize, 215 Debug, 216 Clone, 217 PartialEq, 218 Eq, 219 thiserror::Error, 220 miette::Diagnostic 221)] 222#[serde(tag = "error", content = "message")] 223#[serde(bound(deserialize = "'de: 'a"))] 224pub enum SubscribeReposError<'a> { 225 #[serde(rename = "FutureCursor")] 226 FutureCursor(std::option::Option<String>), 227 ///If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection. 228 #[serde(rename = "ConsumerTooSlow")] 229 ConsumerTooSlow(std::option::Option<String>), 230} 231 232impl std::fmt::Display for SubscribeReposError<'_> { 233 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 234 match self { 235 Self::FutureCursor(msg) => { 236 write!(f, "FutureCursor")?; 237 if let Some(msg) = msg { 238 write!(f, ": {}", msg)?; 239 } 240 Ok(()) 241 } 242 Self::ConsumerTooSlow(msg) => { 243 write!(f, "ConsumerTooSlow")?; 244 if let Some(msg) = msg { 245 write!(f, ": {}", msg)?; 246 } 247 Ok(()) 248 } 249 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 250 } 251 } 252} 253 254impl jacquard_common::IntoStatic for SubscribeReposError<'_> { 255 type Output = SubscribeReposError<'static>; 256 fn into_static(self) -> Self::Output { 257 match self { 258 SubscribeReposError::FutureCursor(v) => { 259 SubscribeReposError::FutureCursor(v.into_static()) 260 } 261 SubscribeReposError::ConsumerTooSlow(v) => { 262 SubscribeReposError::ConsumerTooSlow(v.into_static()) 263 } 264 SubscribeReposError::Unknown(v) => { 265 SubscribeReposError::Unknown(v.into_static()) 266 } 267 } 268 } 269} 270 271///A repo operation, ie a mutation of a single record. 272#[jacquard_derive::lexicon] 273#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 274#[serde(rename_all = "camelCase")] 275pub struct RepoOp<'a> { 276 #[serde(borrow)] 277 pub action: jacquard_common::CowStr<'a>, 278 ///For creates and updates, the new record CID. For deletions, null. 279 #[serde(borrow)] 280 pub cid: jacquard_common::types::cid::CidLink<'a>, 281 #[serde(borrow)] 282 pub path: jacquard_common::CowStr<'a>, 283 ///For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined. 284 #[serde(skip_serializing_if = "std::option::Option::is_none")] 285 #[serde(borrow)] 286 pub prev: std::option::Option<jacquard_common::types::cid::CidLink<'a>>, 287} 288 289impl jacquard_common::IntoStatic for RepoOp<'_> { 290 type Output = RepoOp<'static>; 291 fn into_static(self) -> Self::Output { 292 RepoOp { 293 action: self.action.into_static(), 294 cid: self.cid.into_static(), 295 path: self.path.into_static(), 296 prev: self.prev.into_static(), 297 extra_data: self.extra_data.into_static(), 298 } 299 } 300} 301 302///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. 303#[jacquard_derive::lexicon] 304#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 305#[serde(rename_all = "camelCase")] 306pub struct Sync<'a> { 307 ///CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. 308 pub blocks: bytes::Bytes, 309 ///The account this repo event corresponds to. Must match that in the commit object. 310 #[serde(borrow)] 311 pub did: jacquard_common::types::string::Did<'a>, 312 ///The rev of the commit. This value must match that in the commit object. 313 #[serde(borrow)] 314 pub rev: jacquard_common::CowStr<'a>, 315 ///The stream sequence number of this message. 316 pub seq: i64, 317 ///Timestamp of when this message was originally broadcast. 318 pub time: jacquard_common::types::string::Datetime, 319} 320 321impl jacquard_common::IntoStatic for Sync<'_> { 322 type Output = Sync<'static>; 323 fn into_static(self) -> Self::Output { 324 Sync { 325 blocks: self.blocks.into_static(), 326 did: self.did.into_static(), 327 rev: self.rev.into_static(), 328 seq: self.seq.into_static(), 329 time: self.time.into_static(), 330 extra_data: self.extra_data.into_static(), 331 } 332 } 333}