Skip to main content

jacquard_api/sh_weaver/graph/
get_subscribers.rs

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