Skip to main content

jacquard_api/chat_bsky/moderation/
get_message_context.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: chat.bsky.moderation.getMessageContext
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_derive::{IntoStatic, lexicon, open_union};
15use serde::{Serialize, Deserialize};
16use crate::chat_bsky::convo::DeletedMessageView;
17use crate::chat_bsky::convo::MessageView;
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct GetMessageContext<'a> {
22    ///Defaults to `5`.
23    #[serde(default = "_default_after")]
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub after: Option<i64>,
26    ///Defaults to `5`.
27    #[serde(default = "_default_before")]
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub before: Option<i64>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    #[serde(borrow)]
32    pub convo_id: Option<CowStr<'a>>,
33    #[serde(borrow)]
34    pub message_id: CowStr<'a>,
35}
36
37
38#[lexicon]
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
40#[serde(rename_all = "camelCase")]
41pub struct GetMessageContextOutput<'a> {
42    #[serde(borrow)]
43    pub messages: Vec<GetMessageContextOutputMessagesItem<'a>>,
44}
45
46
47#[open_union]
48#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
49#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
50pub enum GetMessageContextOutputMessagesItem<'a> {
51    #[serde(rename = "chat.bsky.convo.defs#messageView")]
52    MessageView(Box<MessageView<'a>>),
53    #[serde(rename = "chat.bsky.convo.defs#deletedMessageView")]
54    DeletedMessageView(Box<DeletedMessageView<'a>>),
55}
56
57/// Response type for chat.bsky.moderation.getMessageContext
58pub struct GetMessageContextResponse;
59impl jacquard_common::xrpc::XrpcResp for GetMessageContextResponse {
60    const NSID: &'static str = "chat.bsky.moderation.getMessageContext";
61    const ENCODING: &'static str = "application/json";
62    type Output<'de> = GetMessageContextOutput<'de>;
63    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
64}
65
66impl<'a> jacquard_common::xrpc::XrpcRequest for GetMessageContext<'a> {
67    const NSID: &'static str = "chat.bsky.moderation.getMessageContext";
68    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
69    type Response = GetMessageContextResponse;
70}
71
72/// Endpoint type for chat.bsky.moderation.getMessageContext
73pub struct GetMessageContextRequest;
74impl jacquard_common::xrpc::XrpcEndpoint for GetMessageContextRequest {
75    const PATH: &'static str = "/xrpc/chat.bsky.moderation.getMessageContext";
76    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
77    type Request<'de> = GetMessageContext<'de>;
78    type Response = GetMessageContextResponse;
79}
80
81fn _default_after() -> Option<i64> {
82    Some(5i64)
83}
84
85fn _default_before() -> Option<i64> {
86    Some(5i64)
87}
88
89pub mod get_message_context_state {
90
91    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
92    #[allow(unused)]
93    use ::core::marker::PhantomData;
94    mod sealed {
95        pub trait Sealed {}
96    }
97    /// State trait tracking which required fields have been set
98    pub trait State: sealed::Sealed {
99        type MessageId;
100    }
101    /// Empty state - all required fields are unset
102    pub struct Empty(());
103    impl sealed::Sealed for Empty {}
104    impl State for Empty {
105        type MessageId = Unset;
106    }
107    ///State transition - sets the `message_id` field to Set
108    pub struct SetMessageId<S: State = Empty>(PhantomData<fn() -> S>);
109    impl<S: State> sealed::Sealed for SetMessageId<S> {}
110    impl<S: State> State for SetMessageId<S> {
111        type MessageId = Set<members::message_id>;
112    }
113    /// Marker types for field names
114    #[allow(non_camel_case_types)]
115    pub mod members {
116        ///Marker type for the `message_id` field
117        pub struct message_id(());
118    }
119}
120
121/// Builder for constructing an instance of this type
122pub struct GetMessageContextBuilder<'a, S: get_message_context_state::State> {
123    _state: PhantomData<fn() -> S>,
124    _fields: (Option<i64>, Option<i64>, Option<CowStr<'a>>, Option<CowStr<'a>>),
125    _lifetime: PhantomData<&'a ()>,
126}
127
128impl<'a> GetMessageContext<'a> {
129    /// Create a new builder for this type
130    pub fn new() -> GetMessageContextBuilder<'a, get_message_context_state::Empty> {
131        GetMessageContextBuilder::new()
132    }
133}
134
135impl<'a> GetMessageContextBuilder<'a, get_message_context_state::Empty> {
136    /// Create a new builder with all fields unset
137    pub fn new() -> Self {
138        GetMessageContextBuilder {
139            _state: PhantomData,
140            _fields: (None, None, None, None),
141            _lifetime: PhantomData,
142        }
143    }
144}
145
146impl<'a, S: get_message_context_state::State> GetMessageContextBuilder<'a, S> {
147    /// Set the `after` field (optional)
148    pub fn after(mut self, value: impl Into<Option<i64>>) -> Self {
149        self._fields.0 = value.into();
150        self
151    }
152    /// Set the `after` field to an Option value (optional)
153    pub fn maybe_after(mut self, value: Option<i64>) -> Self {
154        self._fields.0 = value;
155        self
156    }
157}
158
159impl<'a, S: get_message_context_state::State> GetMessageContextBuilder<'a, S> {
160    /// Set the `before` field (optional)
161    pub fn before(mut self, value: impl Into<Option<i64>>) -> Self {
162        self._fields.1 = value.into();
163        self
164    }
165    /// Set the `before` field to an Option value (optional)
166    pub fn maybe_before(mut self, value: Option<i64>) -> Self {
167        self._fields.1 = value;
168        self
169    }
170}
171
172impl<'a, S: get_message_context_state::State> GetMessageContextBuilder<'a, S> {
173    /// Set the `convoId` field (optional)
174    pub fn convo_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
175        self._fields.2 = value.into();
176        self
177    }
178    /// Set the `convoId` field to an Option value (optional)
179    pub fn maybe_convo_id(mut self, value: Option<CowStr<'a>>) -> Self {
180        self._fields.2 = value;
181        self
182    }
183}
184
185impl<'a, S> GetMessageContextBuilder<'a, S>
186where
187    S: get_message_context_state::State,
188    S::MessageId: get_message_context_state::IsUnset,
189{
190    /// Set the `messageId` field (required)
191    pub fn message_id(
192        mut self,
193        value: impl Into<CowStr<'a>>,
194    ) -> GetMessageContextBuilder<'a, get_message_context_state::SetMessageId<S>> {
195        self._fields.3 = Option::Some(value.into());
196        GetMessageContextBuilder {
197            _state: PhantomData,
198            _fields: self._fields,
199            _lifetime: PhantomData,
200        }
201    }
202}
203
204impl<'a, S> GetMessageContextBuilder<'a, S>
205where
206    S: get_message_context_state::State,
207    S::MessageId: get_message_context_state::IsSet,
208{
209    /// Build the final struct
210    pub fn build(self) -> GetMessageContext<'a> {
211        GetMessageContext {
212            after: self._fields.0,
213            before: self._fields.1,
214            convo_id: self._fields.2,
215            message_id: self._fields.3.unwrap(),
216        }
217    }
218}