Skip to main content

jacquard_api/place_stream/live/
get_live_users.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.live.getLiveUsers
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::Datetime;
14use jacquard_derive::{IntoStatic, lexicon};
15use serde::{Serialize, Deserialize};
16use crate::place_stream::livestream::LivestreamView;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetLiveUsers {
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}
28
29
30#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
32#[serde(rename_all = "camelCase")]
33pub struct GetLiveUsersOutput<'a> {
34    #[serde(skip_serializing_if = "Option::is_none")]
35    #[serde(borrow)]
36    pub streams: Option<Vec<LivestreamView<'a>>>,
37}
38
39/// Response type for place.stream.live.getLiveUsers
40pub struct GetLiveUsersResponse;
41impl jacquard_common::xrpc::XrpcResp for GetLiveUsersResponse {
42    const NSID: &'static str = "place.stream.live.getLiveUsers";
43    const ENCODING: &'static str = "application/json";
44    type Output<'de> = GetLiveUsersOutput<'de>;
45    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
46}
47
48impl jacquard_common::xrpc::XrpcRequest for GetLiveUsers {
49    const NSID: &'static str = "place.stream.live.getLiveUsers";
50    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
51    type Response = GetLiveUsersResponse;
52}
53
54/// Endpoint type for place.stream.live.getLiveUsers
55pub struct GetLiveUsersRequest;
56impl jacquard_common::xrpc::XrpcEndpoint for GetLiveUsersRequest {
57    const PATH: &'static str = "/xrpc/place.stream.live.getLiveUsers";
58    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
59    type Request<'de> = GetLiveUsers;
60    type Response = GetLiveUsersResponse;
61}
62
63fn _default_limit() -> Option<i64> {
64    Some(50i64)
65}
66
67pub mod get_live_users_state {
68
69    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
70    #[allow(unused)]
71    use ::core::marker::PhantomData;
72    mod sealed {
73        pub trait Sealed {}
74    }
75    /// State trait tracking which required fields have been set
76    pub trait State: sealed::Sealed {}
77    /// Empty state - all required fields are unset
78    pub struct Empty(());
79    impl sealed::Sealed for Empty {}
80    impl State for Empty {}
81    /// Marker types for field names
82    #[allow(non_camel_case_types)]
83    pub mod members {}
84}
85
86/// Builder for constructing an instance of this type
87pub struct GetLiveUsersBuilder<S: get_live_users_state::State> {
88    _state: PhantomData<fn() -> S>,
89    _fields: (Option<Datetime>, Option<i64>),
90}
91
92impl GetLiveUsers {
93    /// Create a new builder for this type
94    pub fn new() -> GetLiveUsersBuilder<get_live_users_state::Empty> {
95        GetLiveUsersBuilder::new()
96    }
97}
98
99impl GetLiveUsersBuilder<get_live_users_state::Empty> {
100    /// Create a new builder with all fields unset
101    pub fn new() -> Self {
102        GetLiveUsersBuilder {
103            _state: PhantomData,
104            _fields: (None, None),
105        }
106    }
107}
108
109impl<S: get_live_users_state::State> GetLiveUsersBuilder<S> {
110    /// Set the `before` field (optional)
111    pub fn before(mut self, value: impl Into<Option<Datetime>>) -> Self {
112        self._fields.0 = value.into();
113        self
114    }
115    /// Set the `before` field to an Option value (optional)
116    pub fn maybe_before(mut self, value: Option<Datetime>) -> Self {
117        self._fields.0 = value;
118        self
119    }
120}
121
122impl<S: get_live_users_state::State> GetLiveUsersBuilder<S> {
123    /// Set the `limit` field (optional)
124    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
125        self._fields.1 = value.into();
126        self
127    }
128    /// Set the `limit` field to an Option value (optional)
129    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
130        self._fields.1 = value;
131        self
132    }
133}
134
135impl<S> GetLiveUsersBuilder<S>
136where
137    S: get_live_users_state::State,
138{
139    /// Build the final struct
140    pub fn build(self) -> GetLiveUsers {
141        GetLiveUsers {
142            before: self._fields.0,
143            limit: self._fields.1,
144        }
145    }
146}