jacquard_api/com_atproto/sync/
get_blocks.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.getBlocks
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9    serde::Serialize,
10    serde::Deserialize,
11    Debug,
12    Clone,
13    PartialEq,
14    Eq,
15    bon::Builder,
16    jacquard_derive::IntoStatic
17)]
18#[builder(start_fn = new)]
19#[serde(rename_all = "camelCase")]
20pub struct GetBlocks<'a> {
21    #[serde(borrow)]
22    pub cids: Vec<jacquard_common::types::string::Cid<'a>>,
23    #[serde(borrow)]
24    pub did: jacquard_common::types::string::Did<'a>,
25}
26
27#[jacquard_derive::lexicon]
28#[derive(
29    serde::Serialize,
30    serde::Deserialize,
31    Debug,
32    Clone,
33    PartialEq,
34    Eq,
35    jacquard_derive::IntoStatic
36)]
37#[serde(rename_all = "camelCase")]
38pub struct GetBlocksOutput<'a> {}
39#[jacquard_derive::open_union]
40#[derive(
41    serde::Serialize,
42    serde::Deserialize,
43    Debug,
44    Clone,
45    PartialEq,
46    Eq,
47    thiserror::Error,
48    miette::Diagnostic,
49    jacquard_derive::IntoStatic
50)]
51#[serde(tag = "error", content = "message")]
52#[serde(bound(deserialize = "'de: 'a"))]
53pub enum GetBlocksError<'a> {
54    #[serde(rename = "BlockNotFound")]
55    BlockNotFound(std::option::Option<String>),
56    #[serde(rename = "RepoNotFound")]
57    RepoNotFound(std::option::Option<String>),
58    #[serde(rename = "RepoTakendown")]
59    RepoTakendown(std::option::Option<String>),
60    #[serde(rename = "RepoSuspended")]
61    RepoSuspended(std::option::Option<String>),
62    #[serde(rename = "RepoDeactivated")]
63    RepoDeactivated(std::option::Option<String>),
64}
65
66impl std::fmt::Display for GetBlocksError<'_> {
67    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
68        match self {
69            Self::BlockNotFound(msg) => {
70                write!(f, "BlockNotFound")?;
71                if let Some(msg) = msg {
72                    write!(f, ": {}", msg)?;
73                }
74                Ok(())
75            }
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
110///com.atproto.sync.getBlocks
111pub struct GetBlocksResponse;
112impl jacquard_common::xrpc::XrpcResp for GetBlocksResponse {
113    const NSID: &'static str = "com.atproto.sync.getBlocks";
114    const ENCODING: &'static str = "application/vnd.ipld.car";
115    type Output<'de> = GetBlocksOutput<'de>;
116    type Err<'de> = GetBlocksError<'de>;
117}
118
119impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for GetBlocks<'de> {
120    const NSID: &'static str = "com.atproto.sync.getBlocks";
121    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
122    type Response = GetBlocksResponse;
123}
124
125///Endpoint type for
126///com.atproto.sync.getBlocks
127pub struct GetBlocksRequest;
128impl jacquard_common::xrpc::XrpcEndpoint for GetBlocksRequest {
129    const PATH: &'static str = "/xrpc/com.atproto.sync.getBlocks";
130    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
131    type Request<'de> = GetBlocks<'de>;
132    type Response = GetBlocksResponse;
133}