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