atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.edit.getBranch
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9 serde::Serialize,
10 serde::Deserialize,
11 Debug,
12 Clone,
13 PartialEq,
14 Eq,
15 jacquard_derive::IntoStatic
16)]
17#[serde(rename_all = "camelCase")]
18pub struct GetBranch<'a> {
19 #[serde(skip_serializing_if = "std::option::Option::is_none")]
20 #[serde(borrow)]
21 pub after_rkey: std::option::Option<jacquard_common::CowStr<'a>>,
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 #[serde(borrow)]
24 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
25 #[serde(borrow)]
26 pub head: jacquard_common::types::string::AtUri<'a>,
27 ///(default: 50, min: 1, max: 100)
28 #[serde(skip_serializing_if = "std::option::Option::is_none")]
29 pub limit: std::option::Option<i64>,
30}
31
32pub mod get_branch_state {
33
34 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
35 #[allow(unused)]
36 use ::core::marker::PhantomData;
37 mod sealed {
38 pub trait Sealed {}
39 }
40 /// State trait tracking which required fields have been set
41 pub trait State: sealed::Sealed {
42 type Head;
43 }
44 /// Empty state - all required fields are unset
45 pub struct Empty(());
46 impl sealed::Sealed for Empty {}
47 impl State for Empty {
48 type Head = Unset;
49 }
50 ///State transition - sets the `head` field to Set
51 pub struct SetHead<S: State = Empty>(PhantomData<fn() -> S>);
52 impl<S: State> sealed::Sealed for SetHead<S> {}
53 impl<S: State> State for SetHead<S> {
54 type Head = Set<members::head>;
55 }
56 /// Marker types for field names
57 #[allow(non_camel_case_types)]
58 pub mod members {
59 ///Marker type for the `head` field
60 pub struct head(());
61 }
62}
63
64/// Builder for constructing an instance of this type
65pub struct GetBranchBuilder<'a, S: get_branch_state::State> {
66 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
67 __unsafe_private_named: (
68 ::core::option::Option<jacquard_common::CowStr<'a>>,
69 ::core::option::Option<jacquard_common::CowStr<'a>>,
70 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
71 ::core::option::Option<i64>,
72 ),
73 _phantom: ::core::marker::PhantomData<&'a ()>,
74}
75
76impl<'a> GetBranch<'a> {
77 /// Create a new builder for this type
78 pub fn new() -> GetBranchBuilder<'a, get_branch_state::Empty> {
79 GetBranchBuilder::new()
80 }
81}
82
83impl<'a> GetBranchBuilder<'a, get_branch_state::Empty> {
84 /// Create a new builder with all fields unset
85 pub fn new() -> Self {
86 GetBranchBuilder {
87 _phantom_state: ::core::marker::PhantomData,
88 __unsafe_private_named: (None, None, None, None),
89 _phantom: ::core::marker::PhantomData,
90 }
91 }
92}
93
94impl<'a, S: get_branch_state::State> GetBranchBuilder<'a, S> {
95 /// Set the `afterRkey` field (optional)
96 pub fn after_rkey(
97 mut self,
98 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
99 ) -> Self {
100 self.__unsafe_private_named.0 = value.into();
101 self
102 }
103 /// Set the `afterRkey` field to an Option value (optional)
104 pub fn maybe_after_rkey(
105 mut self,
106 value: Option<jacquard_common::CowStr<'a>>,
107 ) -> Self {
108 self.__unsafe_private_named.0 = value;
109 self
110 }
111}
112
113impl<'a, S: get_branch_state::State> GetBranchBuilder<'a, S> {
114 /// Set the `cursor` field (optional)
115 pub fn cursor(
116 mut self,
117 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
118 ) -> Self {
119 self.__unsafe_private_named.1 = value.into();
120 self
121 }
122 /// Set the `cursor` field to an Option value (optional)
123 pub fn maybe_cursor(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
124 self.__unsafe_private_named.1 = value;
125 self
126 }
127}
128
129impl<'a, S> GetBranchBuilder<'a, S>
130where
131 S: get_branch_state::State,
132 S::Head: get_branch_state::IsUnset,
133{
134 /// Set the `head` field (required)
135 pub fn head(
136 mut self,
137 value: impl Into<jacquard_common::types::string::AtUri<'a>>,
138 ) -> GetBranchBuilder<'a, get_branch_state::SetHead<S>> {
139 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
140 GetBranchBuilder {
141 _phantom_state: ::core::marker::PhantomData,
142 __unsafe_private_named: self.__unsafe_private_named,
143 _phantom: ::core::marker::PhantomData,
144 }
145 }
146}
147
148impl<'a, S: get_branch_state::State> GetBranchBuilder<'a, S> {
149 /// Set the `limit` field (optional)
150 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
151 self.__unsafe_private_named.3 = value.into();
152 self
153 }
154 /// Set the `limit` field to an Option value (optional)
155 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
156 self.__unsafe_private_named.3 = value;
157 self
158 }
159}
160
161impl<'a, S> GetBranchBuilder<'a, S>
162where
163 S: get_branch_state::State,
164 S::Head: get_branch_state::IsSet,
165{
166 /// Build the final struct
167 pub fn build(self) -> GetBranch<'a> {
168 GetBranch {
169 after_rkey: self.__unsafe_private_named.0,
170 cursor: self.__unsafe_private_named.1,
171 head: self.__unsafe_private_named.2.unwrap(),
172 limit: self.__unsafe_private_named.3,
173 }
174 }
175}
176
177#[jacquard_derive::lexicon]
178#[derive(
179 serde::Serialize,
180 serde::Deserialize,
181 Debug,
182 Clone,
183 PartialEq,
184 Eq,
185 jacquard_derive::IntoStatic
186)]
187#[serde(rename_all = "camelCase")]
188pub struct GetBranchOutput<'a> {
189 #[serde(borrow)]
190 pub branch: crate::sh_weaver::edit::EditBranchView<'a>,
191 #[serde(skip_serializing_if = "std::option::Option::is_none")]
192 #[serde(borrow)]
193 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
194 #[serde(borrow)]
195 pub diffs: Vec<crate::sh_weaver::edit::EditHistoryEntry<'a>>,
196}
197
198/// Response type for
199///sh.weaver.edit.getBranch
200pub struct GetBranchResponse;
201impl jacquard_common::xrpc::XrpcResp for GetBranchResponse {
202 const NSID: &'static str = "sh.weaver.edit.getBranch";
203 const ENCODING: &'static str = "application/json";
204 type Output<'de> = GetBranchOutput<'de>;
205 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
206}
207
208impl<'a> jacquard_common::xrpc::XrpcRequest for GetBranch<'a> {
209 const NSID: &'static str = "sh.weaver.edit.getBranch";
210 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
211 type Response = GetBranchResponse;
212}
213
214/// Endpoint type for
215///sh.weaver.edit.getBranch
216pub struct GetBranchRequest;
217impl jacquard_common::xrpc::XrpcEndpoint for GetBranchRequest {
218 const PATH: &'static str = "/xrpc/sh.weaver.edit.getBranch";
219 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
220 type Request<'de> = GetBranch<'de>;
221 type Response = GetBranchResponse;
222}