Skip to main content

jacquard_api/com_atproto/sync/
list_blobs.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.listBlobs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::{Did, Tid, Cid};
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct ListBlobs<'a> {
21    #[serde(skip_serializing_if = "Option::is_none")]
22    #[serde(borrow)]
23    pub cursor: Option<CowStr<'a>>,
24    #[serde(borrow)]
25    pub did: Did<'a>,
26    ///Defaults to `500`. Min: 1. Max: 1000.
27    #[serde(default = "_default_limit")]
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub limit: Option<i64>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub since: Option<Tid>,
32}
33
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase")]
38pub struct ListBlobsOutput<'a> {
39    #[serde(borrow)]
40    pub cids: Vec<Cid<'a>>,
41    #[serde(skip_serializing_if = "Option::is_none")]
42    #[serde(borrow)]
43    pub cursor: Option<CowStr<'a>>,
44}
45
46
47#[open_union]
48#[derive(
49    Serialize,
50    Deserialize,
51    Debug,
52    Clone,
53    PartialEq,
54    Eq,
55    thiserror::Error,
56    miette::Diagnostic,
57    IntoStatic
58)]
59
60#[serde(tag = "error", content = "message")]
61#[serde(bound(deserialize = "'de: 'a"))]
62pub enum ListBlobsError<'a> {
63    #[serde(rename = "RepoNotFound")]
64    RepoNotFound(Option<CowStr<'a>>),
65    #[serde(rename = "RepoTakendown")]
66    RepoTakendown(Option<CowStr<'a>>),
67    #[serde(rename = "RepoSuspended")]
68    RepoSuspended(Option<CowStr<'a>>),
69    #[serde(rename = "RepoDeactivated")]
70    RepoDeactivated(Option<CowStr<'a>>),
71}
72
73impl core::fmt::Display for ListBlobsError<'_> {
74    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75        match self {
76            Self::RepoNotFound(msg) => {
77                write!(f, "RepoNotFound")?;
78                if let Some(msg) = msg {
79                    write!(f, ": {}", msg)?;
80                }
81                Ok(())
82            }
83            Self::RepoTakendown(msg) => {
84                write!(f, "RepoTakendown")?;
85                if let Some(msg) = msg {
86                    write!(f, ": {}", msg)?;
87                }
88                Ok(())
89            }
90            Self::RepoSuspended(msg) => {
91                write!(f, "RepoSuspended")?;
92                if let Some(msg) = msg {
93                    write!(f, ": {}", msg)?;
94                }
95                Ok(())
96            }
97            Self::RepoDeactivated(msg) => {
98                write!(f, "RepoDeactivated")?;
99                if let Some(msg) = msg {
100                    write!(f, ": {}", msg)?;
101                }
102                Ok(())
103            }
104            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
105        }
106    }
107}
108
109/// Response type for com.atproto.sync.listBlobs
110pub struct ListBlobsResponse;
111impl jacquard_common::xrpc::XrpcResp for ListBlobsResponse {
112    const NSID: &'static str = "com.atproto.sync.listBlobs";
113    const ENCODING: &'static str = "application/json";
114    type Output<'de> = ListBlobsOutput<'de>;
115    type Err<'de> = ListBlobsError<'de>;
116}
117
118impl<'a> jacquard_common::xrpc::XrpcRequest for ListBlobs<'a> {
119    const NSID: &'static str = "com.atproto.sync.listBlobs";
120    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
121    type Response = ListBlobsResponse;
122}
123
124/// Endpoint type for com.atproto.sync.listBlobs
125pub struct ListBlobsRequest;
126impl jacquard_common::xrpc::XrpcEndpoint for ListBlobsRequest {
127    const PATH: &'static str = "/xrpc/com.atproto.sync.listBlobs";
128    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
129    type Request<'de> = ListBlobs<'de>;
130    type Response = ListBlobsResponse;
131}
132
133fn _default_limit() -> Option<i64> {
134    Some(500i64)
135}
136
137pub mod list_blobs_state {
138
139    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
140    #[allow(unused)]
141    use ::core::marker::PhantomData;
142    mod sealed {
143        pub trait Sealed {}
144    }
145    /// State trait tracking which required fields have been set
146    pub trait State: sealed::Sealed {
147        type Did;
148    }
149    /// Empty state - all required fields are unset
150    pub struct Empty(());
151    impl sealed::Sealed for Empty {}
152    impl State for Empty {
153        type Did = Unset;
154    }
155    ///State transition - sets the `did` field to Set
156    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
157    impl<S: State> sealed::Sealed for SetDid<S> {}
158    impl<S: State> State for SetDid<S> {
159        type Did = Set<members::did>;
160    }
161    /// Marker types for field names
162    #[allow(non_camel_case_types)]
163    pub mod members {
164        ///Marker type for the `did` field
165        pub struct did(());
166    }
167}
168
169/// Builder for constructing an instance of this type
170pub struct ListBlobsBuilder<'a, S: list_blobs_state::State> {
171    _state: PhantomData<fn() -> S>,
172    _fields: (Option<CowStr<'a>>, Option<Did<'a>>, Option<i64>, Option<Tid>),
173    _lifetime: PhantomData<&'a ()>,
174}
175
176impl<'a> ListBlobs<'a> {
177    /// Create a new builder for this type
178    pub fn new() -> ListBlobsBuilder<'a, list_blobs_state::Empty> {
179        ListBlobsBuilder::new()
180    }
181}
182
183impl<'a> ListBlobsBuilder<'a, list_blobs_state::Empty> {
184    /// Create a new builder with all fields unset
185    pub fn new() -> Self {
186        ListBlobsBuilder {
187            _state: PhantomData,
188            _fields: (None, None, None, None),
189            _lifetime: PhantomData,
190        }
191    }
192}
193
194impl<'a, S: list_blobs_state::State> ListBlobsBuilder<'a, S> {
195    /// Set the `cursor` field (optional)
196    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
197        self._fields.0 = value.into();
198        self
199    }
200    /// Set the `cursor` field to an Option value (optional)
201    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
202        self._fields.0 = value;
203        self
204    }
205}
206
207impl<'a, S> ListBlobsBuilder<'a, S>
208where
209    S: list_blobs_state::State,
210    S::Did: list_blobs_state::IsUnset,
211{
212    /// Set the `did` field (required)
213    pub fn did(
214        mut self,
215        value: impl Into<Did<'a>>,
216    ) -> ListBlobsBuilder<'a, list_blobs_state::SetDid<S>> {
217        self._fields.1 = Option::Some(value.into());
218        ListBlobsBuilder {
219            _state: PhantomData,
220            _fields: self._fields,
221            _lifetime: PhantomData,
222        }
223    }
224}
225
226impl<'a, S: list_blobs_state::State> ListBlobsBuilder<'a, S> {
227    /// Set the `limit` field (optional)
228    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
229        self._fields.2 = value.into();
230        self
231    }
232    /// Set the `limit` field to an Option value (optional)
233    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
234        self._fields.2 = value;
235        self
236    }
237}
238
239impl<'a, S: list_blobs_state::State> ListBlobsBuilder<'a, S> {
240    /// Set the `since` field (optional)
241    pub fn since(mut self, value: impl Into<Option<Tid>>) -> Self {
242        self._fields.3 = value.into();
243        self
244    }
245    /// Set the `since` field to an Option value (optional)
246    pub fn maybe_since(mut self, value: Option<Tid>) -> Self {
247        self._fields.3 = value;
248        self
249    }
250}
251
252impl<'a, S> ListBlobsBuilder<'a, S>
253where
254    S: list_blobs_state::State,
255    S::Did: list_blobs_state::IsSet,
256{
257    /// Build the final struct
258    pub fn build(self) -> ListBlobs<'a> {
259        ListBlobs {
260            cursor: self._fields.0,
261            did: self._fields.1.unwrap(),
262            limit: self._fields.2,
263            since: self._fields.3,
264        }
265    }
266}