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