Skip to main content

jacquard_api/app_bsky/draft/
delete_draft.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.draft.deleteDraft
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::string::Tid;
16use jacquard_common::types::value::Data;
17use jacquard_derive::IntoStatic;
18use serde::{Serialize, Deserialize};
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
22pub struct DeleteDraft<S: BosStr = DefaultStr> {
23    pub id: Tid,
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.deleteDraft` procedure.
29
30Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `()` for this endpoint.*/
31pub struct DeleteDraftResponse;
32impl jacquard_common::xrpc::XrpcResp for DeleteDraftResponse {
33    const NSID: &'static str = "app.bsky.draft.deleteDraft";
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 DeleteDraft<S> {
40    const NSID: &'static str = "app.bsky.draft.deleteDraft";
41    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
42        "application/json",
43    );
44    type Response = DeleteDraftResponse;
45}
46
47/** Endpoint marker for the `app.bsky.draft.deleteDraft` procedure.
48
49Path: `/xrpc/app.bsky.draft.deleteDraft`. The request payload type is `DeleteDraft<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
50pub struct DeleteDraftRequest;
51impl jacquard_common::xrpc::XrpcEndpoint for DeleteDraftRequest {
52    const PATH: &'static str = "/xrpc/app.bsky.draft.deleteDraft";
53    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
54        "application/json",
55    );
56    type Request<S: BosStr> = DeleteDraft<S>;
57    type Response = DeleteDraftResponse;
58}
59
60pub mod delete_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 Id;
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 Id = Unset;
77    }
78    ///State transition - sets the `id` field to Set
79    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
80    impl<St: State> sealed::Sealed for SetId<St> {}
81    impl<St: State> State for SetId<St> {
82        type Id = Set<members::id>;
83    }
84    /// Marker types for field names
85    #[allow(non_camel_case_types)]
86    pub mod members {
87        ///Marker type for the `id` field
88        pub struct id(());
89    }
90}
91
92/// Builder for constructing an instance of this type.
93pub struct DeleteDraftBuilder<St: delete_draft_state::State, S: BosStr = DefaultStr> {
94    _state: PhantomData<fn() -> St>,
95    _fields: (Option<Tid>,),
96    _type: PhantomData<fn() -> S>,
97}
98
99impl DeleteDraft<DefaultStr> {
100    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
101    pub fn new() -> DeleteDraftBuilder<delete_draft_state::Empty, DefaultStr> {
102        DeleteDraftBuilder::new()
103    }
104}
105
106impl<S: BosStr> DeleteDraft<S> {
107    /// Create a new builder for this type
108    pub fn builder() -> DeleteDraftBuilder<delete_draft_state::Empty, S> {
109        DeleteDraftBuilder::builder()
110    }
111}
112
113impl DeleteDraftBuilder<delete_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        DeleteDraftBuilder {
117            _state: PhantomData,
118            _fields: (None,),
119            _type: PhantomData,
120        }
121    }
122}
123
124impl<S: BosStr> DeleteDraftBuilder<delete_draft_state::Empty, S> {
125    /// Create a new builder with all fields unset
126    pub fn builder() -> Self {
127        DeleteDraftBuilder {
128            _state: PhantomData,
129            _fields: (None,),
130            _type: PhantomData,
131        }
132    }
133}
134
135impl<St, S: BosStr> DeleteDraftBuilder<St, S>
136where
137    St: delete_draft_state::State,
138    St::Id: delete_draft_state::IsUnset,
139{
140    /// Set the `id` field (required)
141    pub fn id(
142        mut self,
143        value: impl Into<Tid>,
144    ) -> DeleteDraftBuilder<delete_draft_state::SetId<St>, S> {
145        self._fields.0 = Option::Some(value.into());
146        DeleteDraftBuilder {
147            _state: PhantomData,
148            _fields: self._fields,
149            _type: PhantomData,
150        }
151    }
152}
153
154impl<St, S: BosStr> DeleteDraftBuilder<St, S>
155where
156    St: delete_draft_state::State,
157    St::Id: delete_draft_state::IsSet,
158{
159    /// Build the final struct.
160    pub fn build(self) -> DeleteDraft<S> {
161        DeleteDraft {
162            id: 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    ) -> DeleteDraft<S> {
171        DeleteDraft {
172            id: self._fields.0.unwrap(),
173            extra_data: Some(extra_data),
174        }
175    }
176}