jacquard_api/com_atproto/
repo.rs1pub mod apply_writes;
9pub mod create_record;
10pub mod delete_record;
11pub mod describe_repo;
12pub mod get_record;
13pub mod import_repo;
14pub mod list_missing_blobs;
15pub mod list_records;
16pub mod put_record;
17pub mod strong_ref;
18pub mod upload_blob;
19
20
21#[allow(unused_imports)]
22use alloc::collections::BTreeMap;
23
24#[allow(unused_imports)]
25use core::marker::PhantomData;
26
27#[allow(unused_imports)]
28use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
29use jacquard_common::types::string::{Tid, Cid};
30use jacquard_derive::{IntoStatic, lexicon};
31use jacquard_lexicon::lexicon::LexiconDoc;
32use jacquard_lexicon::schema::LexiconSchema;
33
34#[allow(unused_imports)]
35use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
36use serde::{Serialize, Deserialize};
37
38#[lexicon]
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
40#[serde(rename_all = "camelCase")]
41pub struct CommitMeta<'a> {
42 #[serde(borrow)]
43 pub cid: Cid<'a>,
44 pub rev: Tid,
45}
46
47impl<'a> LexiconSchema for CommitMeta<'a> {
48 fn nsid() -> &'static str {
49 "com.atproto.repo.defs"
50 }
51 fn def_name() -> &'static str {
52 "commitMeta"
53 }
54 fn lexicon_doc() -> LexiconDoc<'static> {
55 lexicon_doc_com_atproto_repo_defs()
56 }
57 fn validate(&self) -> Result<(), ConstraintError> {
58 Ok(())
59 }
60}
61
62pub mod commit_meta_state {
63
64 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
65 #[allow(unused)]
66 use ::core::marker::PhantomData;
67 mod sealed {
68 pub trait Sealed {}
69 }
70 pub trait State: sealed::Sealed {
72 type Cid;
73 type Rev;
74 }
75 pub struct Empty(());
77 impl sealed::Sealed for Empty {}
78 impl State for Empty {
79 type Cid = Unset;
80 type Rev = Unset;
81 }
82 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
84 impl<S: State> sealed::Sealed for SetCid<S> {}
85 impl<S: State> State for SetCid<S> {
86 type Cid = Set<members::cid>;
87 type Rev = S::Rev;
88 }
89 pub struct SetRev<S: State = Empty>(PhantomData<fn() -> S>);
91 impl<S: State> sealed::Sealed for SetRev<S> {}
92 impl<S: State> State for SetRev<S> {
93 type Cid = S::Cid;
94 type Rev = Set<members::rev>;
95 }
96 #[allow(non_camel_case_types)]
98 pub mod members {
99 pub struct cid(());
101 pub struct rev(());
103 }
104}
105
106pub struct CommitMetaBuilder<'a, S: commit_meta_state::State> {
108 _state: PhantomData<fn() -> S>,
109 _fields: (Option<Cid<'a>>, Option<Tid>),
110 _lifetime: PhantomData<&'a ()>,
111}
112
113impl<'a> CommitMeta<'a> {
114 pub fn new() -> CommitMetaBuilder<'a, commit_meta_state::Empty> {
116 CommitMetaBuilder::new()
117 }
118}
119
120impl<'a> CommitMetaBuilder<'a, commit_meta_state::Empty> {
121 pub fn new() -> Self {
123 CommitMetaBuilder {
124 _state: PhantomData,
125 _fields: (None, None),
126 _lifetime: PhantomData,
127 }
128 }
129}
130
131impl<'a, S> CommitMetaBuilder<'a, S>
132where
133 S: commit_meta_state::State,
134 S::Cid: commit_meta_state::IsUnset,
135{
136 pub fn cid(
138 mut self,
139 value: impl Into<Cid<'a>>,
140 ) -> CommitMetaBuilder<'a, commit_meta_state::SetCid<S>> {
141 self._fields.0 = Option::Some(value.into());
142 CommitMetaBuilder {
143 _state: PhantomData,
144 _fields: self._fields,
145 _lifetime: PhantomData,
146 }
147 }
148}
149
150impl<'a, S> CommitMetaBuilder<'a, S>
151where
152 S: commit_meta_state::State,
153 S::Rev: commit_meta_state::IsUnset,
154{
155 pub fn rev(
157 mut self,
158 value: impl Into<Tid>,
159 ) -> CommitMetaBuilder<'a, commit_meta_state::SetRev<S>> {
160 self._fields.1 = Option::Some(value.into());
161 CommitMetaBuilder {
162 _state: PhantomData,
163 _fields: self._fields,
164 _lifetime: PhantomData,
165 }
166 }
167}
168
169impl<'a, S> CommitMetaBuilder<'a, S>
170where
171 S: commit_meta_state::State,
172 S::Cid: commit_meta_state::IsSet,
173 S::Rev: commit_meta_state::IsSet,
174{
175 pub fn build(self) -> CommitMeta<'a> {
177 CommitMeta {
178 cid: self._fields.0.unwrap(),
179 rev: self._fields.1.unwrap(),
180 extra_data: Default::default(),
181 }
182 }
183 pub fn build_with_data(
185 self,
186 extra_data: BTreeMap<
187 jacquard_common::deps::smol_str::SmolStr,
188 jacquard_common::types::value::Data<'a>,
189 >,
190 ) -> CommitMeta<'a> {
191 CommitMeta {
192 cid: self._fields.0.unwrap(),
193 rev: self._fields.1.unwrap(),
194 extra_data: Some(extra_data),
195 }
196 }
197}
198
199fn lexicon_doc_com_atproto_repo_defs() -> LexiconDoc<'static> {
200 #[allow(unused_imports)]
201 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
202 use jacquard_lexicon::lexicon::*;
203 use alloc::collections::BTreeMap;
204 LexiconDoc {
205 lexicon: Lexicon::Lexicon1,
206 id: CowStr::new_static("com.atproto.repo.defs"),
207 defs: {
208 let mut map = BTreeMap::new();
209 map.insert(
210 SmolStr::new_static("commitMeta"),
211 LexUserType::Object(LexObject {
212 required: Some(
213 vec![SmolStr::new_static("cid"), SmolStr::new_static("rev")],
214 ),
215 properties: {
216 #[allow(unused_mut)]
217 let mut map = BTreeMap::new();
218 map.insert(
219 SmolStr::new_static("cid"),
220 LexObjectProperty::String(LexString {
221 format: Some(LexStringFormat::Cid),
222 ..Default::default()
223 }),
224 );
225 map.insert(
226 SmolStr::new_static("rev"),
227 LexObjectProperty::String(LexString {
228 format: Some(LexStringFormat::Tid),
229 ..Default::default()
230 }),
231 );
232 map
233 },
234 ..Default::default()
235 }),
236 );
237 map
238 },
239 ..Default::default()
240 }
241}