atrium_api/com/atproto/sync/
subscribe_repos.rs

1// @generated - This file is generated by atrium-codegen. DO NOT EDIT.
2//!Definitions for the `com.atproto.sync.subscribeRepos` namespace.
3pub const NSID: &str = "com.atproto.sync.subscribeRepos";
4#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
5#[serde(rename_all = "camelCase")]
6pub struct ParametersData {
7    ///The last known event seq number to backfill from.
8    #[serde(skip_serializing_if = "core::option::Option::is_none")]
9    pub cursor: core::option::Option<i64>,
10}
11pub type Parameters = crate::types::Object<ParametersData>;
12#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
13#[serde(tag = "error", content = "message")]
14pub enum Error {
15    FutureCursor(Option<String>),
16    ///If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.
17    ConsumerTooSlow(Option<String>),
18}
19impl std::fmt::Display for Error {
20    fn fmt(&self, _f: &mut std::fmt::Formatter) -> std::fmt::Result {
21        match self {
22            Error::FutureCursor(msg) => {
23                write!(_f, "FutureCursor")?;
24                if let Some(msg) = msg {
25                    write!(_f, ": {msg}")?;
26                }
27            }
28            Error::ConsumerTooSlow(msg) => {
29                write!(_f, "ConsumerTooSlow")?;
30                if let Some(msg) = msg {
31                    write!(_f, ": {msg}")?;
32                }
33            }
34        }
35        Ok(())
36    }
37}
38///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.
39#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
40#[serde(rename_all = "camelCase")]
41pub struct AccountData {
42    ///Indicates that the account has a repository which can be fetched from the host that emitted this event.
43    pub active: bool,
44    pub did: crate::types::string::Did,
45    pub seq: i64,
46    ///If active=false, this optional field indicates a reason for why the account is not active.
47    #[serde(skip_serializing_if = "core::option::Option::is_none")]
48    pub status: core::option::Option<String>,
49    pub time: crate::types::string::Datetime,
50}
51pub type Account = crate::types::Object<AccountData>;
52///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.
53#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
54#[serde(rename_all = "camelCase")]
55pub struct CommitData {
56    pub blobs: Vec<crate::types::CidLink>,
57    ///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.
58    #[serde(with = "serde_bytes")]
59    pub blocks: Vec<u8>,
60    ///Repo commit object CID.
61    pub commit: crate::types::CidLink,
62    pub ops: Vec<RepoOp>,
63    ///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.
64    #[serde(skip_serializing_if = "core::option::Option::is_none")]
65    pub prev_data: core::option::Option<crate::types::CidLink>,
66    ///DEPRECATED -- unused
67    pub rebase: bool,
68    ///The repo this event comes from. Note that all other message types name this field 'did'.
69    pub repo: crate::types::string::Did,
70    ///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.
71    pub rev: crate::types::string::Tid,
72    ///The stream sequence number of this message.
73    pub seq: i64,
74    ///The rev of the last emitted commit from this repo (if any).
75    #[serde(skip_serializing_if = "core::option::Option::is_none")]
76    pub since: core::option::Option<crate::types::string::Tid>,
77    ///Timestamp of when this message was originally broadcast.
78    pub time: crate::types::string::Datetime,
79    ///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.
80    pub too_big: bool,
81}
82pub type Commit = crate::types::Object<CommitData>;
83///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.
84#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
85#[serde(rename_all = "camelCase")]
86pub struct IdentityData {
87    pub did: crate::types::string::Did,
88    ///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.
89    #[serde(skip_serializing_if = "core::option::Option::is_none")]
90    pub handle: core::option::Option<crate::types::string::Handle>,
91    pub seq: i64,
92    pub time: crate::types::string::Datetime,
93}
94pub type Identity = crate::types::Object<IdentityData>;
95#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
96#[serde(rename_all = "camelCase")]
97pub struct InfoData {
98    #[serde(skip_serializing_if = "core::option::Option::is_none")]
99    pub message: core::option::Option<String>,
100    pub name: String,
101}
102pub type Info = crate::types::Object<InfoData>;
103///A repo operation, ie a mutation of a single record.
104#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
105#[serde(rename_all = "camelCase")]
106pub struct RepoOpData {
107    pub action: String,
108    ///For creates and updates, the new record CID. For deletions, null.
109    #[serde(skip_serializing_if = "core::option::Option::is_none")]
110    pub cid: core::option::Option<crate::types::CidLink>,
111    pub path: String,
112    ///For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.
113    #[serde(skip_serializing_if = "core::option::Option::is_none")]
114    pub prev: core::option::Option<crate::types::CidLink>,
115}
116pub type RepoOp = crate::types::Object<RepoOpData>;
117///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.
118#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
119#[serde(rename_all = "camelCase")]
120pub struct SyncData {
121    ///CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.
122    #[serde(with = "serde_bytes")]
123    pub blocks: Vec<u8>,
124    ///The account this repo event corresponds to. Must match that in the commit object.
125    pub did: crate::types::string::Did,
126    ///The rev of the commit. This value must match that in the commit object.
127    pub rev: String,
128    ///The stream sequence number of this message.
129    pub seq: i64,
130    ///Timestamp of when this message was originally broadcast.
131    pub time: crate::types::string::Datetime,
132}
133pub type Sync = crate::types::Object<SyncData>;
134#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
135#[serde(tag = "$type")]
136pub enum Message {
137    #[serde(rename = "com.atproto.sync.subscribeRepos#commit")]
138    Commit(Box<Commit>),
139    #[serde(rename = "com.atproto.sync.subscribeRepos#sync")]
140    Sync(Box<Sync>),
141    #[serde(rename = "com.atproto.sync.subscribeRepos#identity")]
142    Identity(Box<Identity>),
143    #[serde(rename = "com.atproto.sync.subscribeRepos#account")]
144    Account(Box<Account>),
145    #[serde(rename = "com.atproto.sync.subscribeRepos#info")]
146    Info(Box<Info>),
147}