Skip to main content

jacquard_api/sh_weaver/graph/
get_list.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.graph.getList
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, open_union};
16use serde::{Serialize, Deserialize};
17use crate::sh_weaver::graph::ListItemView;
18use crate::sh_weaver::graph::ListView;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase")]
22pub struct GetList<'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 list: AtUri<'a>,
32}
33
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase")]
38pub struct GetListOutput<'a> {
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(borrow)]
41    pub cursor: Option<CowStr<'a>>,
42    #[serde(borrow)]
43    pub items: Vec<ListItemView<'a>>,
44    #[serde(borrow)]
45    pub list: ListView<'a>,
46}
47
48
49#[open_union]
50#[derive(
51    Serialize,
52    Deserialize,
53    Debug,
54    Clone,
55    PartialEq,
56    Eq,
57    thiserror::Error,
58    miette::Diagnostic,
59    IntoStatic
60)]
61
62#[serde(tag = "error", content = "message")]
63#[serde(bound(deserialize = "'de: 'a"))]
64pub enum GetListError<'a> {
65    #[serde(rename = "ListNotFound")]
66    ListNotFound(Option<CowStr<'a>>),
67}
68
69impl core::fmt::Display for GetListError<'_> {
70    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71        match self {
72            Self::ListNotFound(msg) => {
73                write!(f, "ListNotFound")?;
74                if let Some(msg) = msg {
75                    write!(f, ": {}", msg)?;
76                }
77                Ok(())
78            }
79            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
80        }
81    }
82}
83
84/// Response type for sh.weaver.graph.getList
85pub struct GetListResponse;
86impl jacquard_common::xrpc::XrpcResp for GetListResponse {
87    const NSID: &'static str = "sh.weaver.graph.getList";
88    const ENCODING: &'static str = "application/json";
89    type Output<'de> = GetListOutput<'de>;
90    type Err<'de> = GetListError<'de>;
91}
92
93impl<'a> jacquard_common::xrpc::XrpcRequest for GetList<'a> {
94    const NSID: &'static str = "sh.weaver.graph.getList";
95    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
96    type Response = GetListResponse;
97}
98
99/// Endpoint type for sh.weaver.graph.getList
100pub struct GetListRequest;
101impl jacquard_common::xrpc::XrpcEndpoint for GetListRequest {
102    const PATH: &'static str = "/xrpc/sh.weaver.graph.getList";
103    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
104    type Request<'de> = GetList<'de>;
105    type Response = GetListResponse;
106}
107
108fn _default_limit() -> Option<i64> {
109    Some(50i64)
110}
111
112pub mod get_list_state {
113
114    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
115    #[allow(unused)]
116    use ::core::marker::PhantomData;
117    mod sealed {
118        pub trait Sealed {}
119    }
120    /// State trait tracking which required fields have been set
121    pub trait State: sealed::Sealed {
122        type List;
123    }
124    /// Empty state - all required fields are unset
125    pub struct Empty(());
126    impl sealed::Sealed for Empty {}
127    impl State for Empty {
128        type List = Unset;
129    }
130    ///State transition - sets the `list` field to Set
131    pub struct SetList<S: State = Empty>(PhantomData<fn() -> S>);
132    impl<S: State> sealed::Sealed for SetList<S> {}
133    impl<S: State> State for SetList<S> {
134        type List = Set<members::list>;
135    }
136    /// Marker types for field names
137    #[allow(non_camel_case_types)]
138    pub mod members {
139        ///Marker type for the `list` field
140        pub struct list(());
141    }
142}
143
144/// Builder for constructing an instance of this type
145pub struct GetListBuilder<'a, S: get_list_state::State> {
146    _state: PhantomData<fn() -> S>,
147    _fields: (Option<CowStr<'a>>, Option<i64>, Option<AtUri<'a>>),
148    _lifetime: PhantomData<&'a ()>,
149}
150
151impl<'a> GetList<'a> {
152    /// Create a new builder for this type
153    pub fn new() -> GetListBuilder<'a, get_list_state::Empty> {
154        GetListBuilder::new()
155    }
156}
157
158impl<'a> GetListBuilder<'a, get_list_state::Empty> {
159    /// Create a new builder with all fields unset
160    pub fn new() -> Self {
161        GetListBuilder {
162            _state: PhantomData,
163            _fields: (None, None, None),
164            _lifetime: PhantomData,
165        }
166    }
167}
168
169impl<'a, S: get_list_state::State> GetListBuilder<'a, S> {
170    /// Set the `cursor` field (optional)
171    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
172        self._fields.0 = value.into();
173        self
174    }
175    /// Set the `cursor` field to an Option value (optional)
176    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
177        self._fields.0 = value;
178        self
179    }
180}
181
182impl<'a, S: get_list_state::State> GetListBuilder<'a, S> {
183    /// Set the `limit` field (optional)
184    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
185        self._fields.1 = value.into();
186        self
187    }
188    /// Set the `limit` field to an Option value (optional)
189    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
190        self._fields.1 = value;
191        self
192    }
193}
194
195impl<'a, S> GetListBuilder<'a, S>
196where
197    S: get_list_state::State,
198    S::List: get_list_state::IsUnset,
199{
200    /// Set the `list` field (required)
201    pub fn list(
202        mut self,
203        value: impl Into<AtUri<'a>>,
204    ) -> GetListBuilder<'a, get_list_state::SetList<S>> {
205        self._fields.2 = Option::Some(value.into());
206        GetListBuilder {
207            _state: PhantomData,
208            _fields: self._fields,
209            _lifetime: PhantomData,
210        }
211    }
212}
213
214impl<'a, S> GetListBuilder<'a, S>
215where
216    S: get_list_state::State,
217    S::List: get_list_state::IsSet,
218{
219    /// Build the final struct
220    pub fn build(self) -> GetList<'a> {
221        GetList {
222            cursor: self._fields.0,
223            limit: self._fields.1,
224            list: self._fields.2.unwrap(),
225        }
226    }
227}