Skip to main content

jacquard_api/app_bsky/draft/
update_draft.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.draft.updateDraft
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::{BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::value::Data;
16use jacquard_derive::IntoStatic;
17use serde::{Serialize, Deserialize};
18use crate::app_bsky::draft::DraftWithId;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
22pub struct UpdateDraft<S: BosStr = DefaultStr> {
23    pub draft: DraftWithId<S>,
24    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
25    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
26}
27
28/** Response marker for the `app.bsky.draft.updateDraft` procedure.
29
30Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `()` for this endpoint.*/
31pub struct UpdateDraftResponse;
32impl jacquard_common::xrpc::XrpcResp for UpdateDraftResponse {
33    const NSID: &'static str = "app.bsky.draft.updateDraft";
34    const ENCODING: &'static str = "application/json";
35    type Output<S: BosStr> = ();
36    type Err = jacquard_common::xrpc::GenericError;
37}
38
39impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for UpdateDraft<S> {
40    const NSID: &'static str = "app.bsky.draft.updateDraft";
41    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
42        "application/json",
43    );
44    type Response = UpdateDraftResponse;
45}
46
47/** Endpoint marker for the `app.bsky.draft.updateDraft` procedure.
48
49Path: `/xrpc/app.bsky.draft.updateDraft`. The request payload type is `UpdateDraft<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
50pub struct UpdateDraftRequest;
51impl jacquard_common::xrpc::XrpcEndpoint for UpdateDraftRequest {
52    const PATH: &'static str = "/xrpc/app.bsky.draft.updateDraft";
53    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
54        "application/json",
55    );
56    type Request<S: BosStr> = UpdateDraft<S>;
57    type Response = UpdateDraftResponse;
58}
59
60pub mod update_draft_state {
61
62    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
63    #[allow(unused)]
64    use ::core::marker::PhantomData;
65    mod sealed {
66        pub trait Sealed {}
67    }
68    /// State trait tracking which required fields have been set
69    pub trait State: sealed::Sealed {
70        type Draft;
71    }
72    /// Empty state - all required fields are unset
73    pub struct Empty(());
74    impl sealed::Sealed for Empty {}
75    impl State for Empty {
76        type Draft = Unset;
77    }
78    ///State transition - sets the `draft` field to Set
79    pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
80    impl<St: State> sealed::Sealed for SetDraft<St> {}
81    impl<St: State> State for SetDraft<St> {
82        type Draft = Set<members::draft>;
83    }
84    /// Marker types for field names
85    #[allow(non_camel_case_types)]
86    pub mod members {
87        ///Marker type for the `draft` field
88        pub struct draft(());
89    }
90}
91
92/// Builder for constructing an instance of this type.
93pub struct UpdateDraftBuilder<St: update_draft_state::State, S: BosStr = DefaultStr> {
94    _state: PhantomData<fn() -> St>,
95    _fields: (Option<DraftWithId<S>>,),
96    _type: PhantomData<fn() -> S>,
97}
98
99impl UpdateDraft<DefaultStr> {
100    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
101    pub fn new() -> UpdateDraftBuilder<update_draft_state::Empty, DefaultStr> {
102        UpdateDraftBuilder::new()
103    }
104}
105
106impl<S: BosStr> UpdateDraft<S> {
107    /// Create a new builder for this type
108    pub fn builder() -> UpdateDraftBuilder<update_draft_state::Empty, S> {
109        UpdateDraftBuilder::builder()
110    }
111}
112
113impl UpdateDraftBuilder<update_draft_state::Empty, DefaultStr> {
114    /// Create a new builder with all fields unset, using the default string type, if needed
115    pub fn new() -> Self {
116        UpdateDraftBuilder {
117            _state: PhantomData,
118            _fields: (None,),
119            _type: PhantomData,
120        }
121    }
122}
123
124impl<S: BosStr> UpdateDraftBuilder<update_draft_state::Empty, S> {
125    /// Create a new builder with all fields unset
126    pub fn builder() -> Self {
127        UpdateDraftBuilder {
128            _state: PhantomData,
129            _fields: (None,),
130            _type: PhantomData,
131        }
132    }
133}
134
135impl<St, S: BosStr> UpdateDraftBuilder<St, S>
136where
137    St: update_draft_state::State,
138    St::Draft: update_draft_state::IsUnset,
139{
140    /// Set the `draft` field (required)
141    pub fn draft(
142        mut self,
143        value: impl Into<DraftWithId<S>>,
144    ) -> UpdateDraftBuilder<update_draft_state::SetDraft<St>, S> {
145        self._fields.0 = Option::Some(value.into());
146        UpdateDraftBuilder {
147            _state: PhantomData,
148            _fields: self._fields,
149            _type: PhantomData,
150        }
151    }
152}
153
154impl<St, S: BosStr> UpdateDraftBuilder<St, S>
155where
156    St: update_draft_state::State,
157    St::Draft: update_draft_state::IsSet,
158{
159    /// Build the final struct.
160    pub fn build(self) -> UpdateDraft<S> {
161        UpdateDraft {
162            draft: self._fields.0.unwrap(),
163            extra_data: Default::default(),
164        }
165    }
166    /// Build the final struct with custom extra_data.
167    pub fn build_with_data(
168        self,
169        extra_data: BTreeMap<SmolStr, Data<S>>,
170    ) -> UpdateDraft<S> {
171        UpdateDraft {
172            draft: self._fields.0.unwrap(),
173            extra_data: Some(extra_data),
174        }
175    }
176}