Skip to main content

jacquard_api/com_atproto/temp/
fetch_labels.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.temp.fetchLabels
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::{BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::value::Data;
16use jacquard_derive::IntoStatic;
17use serde::{Serialize, Deserialize};
18use crate::com_atproto::label::Label;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase")]
22pub struct FetchLabels {
23    /// Defaults to `50`. Min: 1. Max: 250.
24    #[serde(default = "_default_limit")]
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub limit: Option<i64>,
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub since: Option<i64>,
29}
30
31
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
34pub struct FetchLabelsOutput<S: BosStr = DefaultStr> {
35    pub labels: Vec<Label<S>>,
36    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
37    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
38}
39
40/** Response marker for the `com.atproto.temp.fetchLabels` query.
41
42Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `FetchLabelsOutput<S>` for this endpoint.*/
43pub struct FetchLabelsResponse;
44impl jacquard_common::xrpc::XrpcResp for FetchLabelsResponse {
45    const NSID: &'static str = "com.atproto.temp.fetchLabels";
46    const ENCODING: &'static str = "application/json";
47    type Output<S: BosStr> = FetchLabelsOutput<S>;
48    type Err = jacquard_common::xrpc::GenericError;
49}
50
51impl jacquard_common::xrpc::XrpcRequest for FetchLabels {
52    const NSID: &'static str = "com.atproto.temp.fetchLabels";
53    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
54    type Response = FetchLabelsResponse;
55}
56
57/** Endpoint marker for the `com.atproto.temp.fetchLabels` query.
58
59Path: `/xrpc/com.atproto.temp.fetchLabels`. The request payload type is `FetchLabels`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
60pub struct FetchLabelsRequest;
61impl jacquard_common::xrpc::XrpcEndpoint for FetchLabelsRequest {
62    const PATH: &'static str = "/xrpc/com.atproto.temp.fetchLabels";
63    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
64    type Request<S: BosStr> = FetchLabels;
65    type Response = FetchLabelsResponse;
66}
67
68fn _default_limit() -> Option<i64> {
69    Some(50i64)
70}
71
72pub mod fetch_labels_state {
73
74    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
75    #[allow(unused)]
76    use ::core::marker::PhantomData;
77    mod sealed {
78        pub trait Sealed {}
79    }
80    /// State trait tracking which required fields have been set
81    pub trait State: sealed::Sealed {}
82    /// Empty state - all required fields are unset
83    pub struct Empty(());
84    impl sealed::Sealed for Empty {}
85    impl State for Empty {}
86    /// Marker types for field names
87    #[allow(non_camel_case_types)]
88    pub mod members {}
89}
90
91/// Builder for constructing an instance of this type.
92pub struct FetchLabelsBuilder<St: fetch_labels_state::State> {
93    _state: PhantomData<fn() -> St>,
94    _fields: (Option<i64>, Option<i64>),
95}
96
97impl FetchLabels {
98    /// Create a new builder for this type.
99    pub fn new() -> FetchLabelsBuilder<fetch_labels_state::Empty> {
100        FetchLabelsBuilder::new()
101    }
102}
103
104impl FetchLabelsBuilder<fetch_labels_state::Empty> {
105    /// Create a new builder with all fields unset, using the default string type, if needed
106    pub fn new() -> Self {
107        FetchLabelsBuilder {
108            _state: PhantomData,
109            _fields: (None, None),
110        }
111    }
112}
113
114impl FetchLabelsBuilder<fetch_labels_state::Empty> {
115    /// Create a new builder with all fields unset
116    pub fn builder() -> Self {
117        FetchLabelsBuilder {
118            _state: PhantomData,
119            _fields: (None, None),
120        }
121    }
122}
123
124impl<St: fetch_labels_state::State> FetchLabelsBuilder<St> {
125    /// Set the `limit` field (optional)
126    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
127        self._fields.0 = value.into();
128        self
129    }
130    /// Set the `limit` field to an Option value (optional)
131    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
132        self._fields.0 = value;
133        self
134    }
135}
136
137impl<St: fetch_labels_state::State> FetchLabelsBuilder<St> {
138    /// Set the `since` field (optional)
139    pub fn since(mut self, value: impl Into<Option<i64>>) -> Self {
140        self._fields.1 = value.into();
141        self
142    }
143    /// Set the `since` field to an Option value (optional)
144    pub fn maybe_since(mut self, value: Option<i64>) -> Self {
145        self._fields.1 = value;
146        self
147    }
148}
149
150impl<St> FetchLabelsBuilder<St>
151where
152    St: fetch_labels_state::State,
153{
154    /// Build the final struct.
155    pub fn build(self) -> FetchLabels {
156        FetchLabels {
157            limit: self._fields.0,
158            since: self._fields.1,
159        }
160    }
161}