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