Skip to main content

jacquard_api/app_bsky/graph/
get_blocks.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.graph.getBlocks
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_derive::{IntoStatic, lexicon};
15use serde::{Serialize, Deserialize};
16use crate::app_bsky::actor::ProfileView;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetBlocks<'a> {
21    #[serde(skip_serializing_if = "Option::is_none")]
22    #[serde(borrow)]
23    pub cursor: Option<CowStr<'a>>,
24    ///Defaults to `50`. Min: 1. Max: 100.
25    #[serde(default = "_default_limit")]
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub limit: Option<i64>,
28}
29
30
31#[lexicon]
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase")]
34pub struct GetBlocksOutput<'a> {
35    #[serde(borrow)]
36    pub blocks: Vec<ProfileView<'a>>,
37    #[serde(skip_serializing_if = "Option::is_none")]
38    #[serde(borrow)]
39    pub cursor: Option<CowStr<'a>>,
40}
41
42/// Response type for app.bsky.graph.getBlocks
43pub struct GetBlocksResponse;
44impl jacquard_common::xrpc::XrpcResp for GetBlocksResponse {
45    const NSID: &'static str = "app.bsky.graph.getBlocks";
46    const ENCODING: &'static str = "application/json";
47    type Output<'de> = GetBlocksOutput<'de>;
48    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
49}
50
51impl<'a> jacquard_common::xrpc::XrpcRequest for GetBlocks<'a> {
52    const NSID: &'static str = "app.bsky.graph.getBlocks";
53    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
54    type Response = GetBlocksResponse;
55}
56
57/// Endpoint type for app.bsky.graph.getBlocks
58pub struct GetBlocksRequest;
59impl jacquard_common::xrpc::XrpcEndpoint for GetBlocksRequest {
60    const PATH: &'static str = "/xrpc/app.bsky.graph.getBlocks";
61    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
62    type Request<'de> = GetBlocks<'de>;
63    type Response = GetBlocksResponse;
64}
65
66fn _default_limit() -> Option<i64> {
67    Some(50i64)
68}
69
70pub mod get_blocks_state {
71
72    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
73    #[allow(unused)]
74    use ::core::marker::PhantomData;
75    mod sealed {
76        pub trait Sealed {}
77    }
78    /// State trait tracking which required fields have been set
79    pub trait State: sealed::Sealed {}
80    /// Empty state - all required fields are unset
81    pub struct Empty(());
82    impl sealed::Sealed for Empty {}
83    impl State for Empty {}
84    /// Marker types for field names
85    #[allow(non_camel_case_types)]
86    pub mod members {}
87}
88
89/// Builder for constructing an instance of this type
90pub struct GetBlocksBuilder<'a, S: get_blocks_state::State> {
91    _state: PhantomData<fn() -> S>,
92    _fields: (Option<CowStr<'a>>, Option<i64>),
93    _lifetime: PhantomData<&'a ()>,
94}
95
96impl<'a> GetBlocks<'a> {
97    /// Create a new builder for this type
98    pub fn new() -> GetBlocksBuilder<'a, get_blocks_state::Empty> {
99        GetBlocksBuilder::new()
100    }
101}
102
103impl<'a> GetBlocksBuilder<'a, get_blocks_state::Empty> {
104    /// Create a new builder with all fields unset
105    pub fn new() -> Self {
106        GetBlocksBuilder {
107            _state: PhantomData,
108            _fields: (None, None),
109            _lifetime: PhantomData,
110        }
111    }
112}
113
114impl<'a, S: get_blocks_state::State> GetBlocksBuilder<'a, S> {
115    /// Set the `cursor` field (optional)
116    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
117        self._fields.0 = value.into();
118        self
119    }
120    /// Set the `cursor` field to an Option value (optional)
121    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
122        self._fields.0 = value;
123        self
124    }
125}
126
127impl<'a, S: get_blocks_state::State> GetBlocksBuilder<'a, S> {
128    /// Set the `limit` field (optional)
129    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
130        self._fields.1 = value.into();
131        self
132    }
133    /// Set the `limit` field to an Option value (optional)
134    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
135        self._fields.1 = value;
136        self
137    }
138}
139
140impl<'a, S> GetBlocksBuilder<'a, S>
141where
142    S: get_blocks_state::State,
143{
144    /// Build the final struct
145    pub fn build(self) -> GetBlocks<'a> {
146        GetBlocks {
147            cursor: self._fields.0,
148            limit: self._fields.1,
149        }
150    }
151}