Skip to main content

jacquard_api/place_stream/live/
get_segments.rs

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