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