A better Rust ATProto crate
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.repo.applyWrites 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8///Operation which creates a new record. 9#[jacquard_derive::lexicon] 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic 18)] 19#[serde(rename_all = "camelCase")] 20pub struct Create<'a> { 21 #[serde(borrow)] 22 pub collection: jacquard_common::types::string::Nsid<'a>, 23 ///NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility. 24 #[serde(skip_serializing_if = "std::option::Option::is_none")] 25 #[serde(borrow)] 26 pub rkey: std::option::Option< 27 jacquard_common::types::string::RecordKey< 28 jacquard_common::types::string::Rkey<'a>, 29 >, 30 >, 31 #[serde(borrow)] 32 pub value: jacquard_common::types::value::Data<'a>, 33} 34 35#[jacquard_derive::lexicon] 36#[derive( 37 serde::Serialize, 38 serde::Deserialize, 39 Debug, 40 Clone, 41 PartialEq, 42 Eq, 43 jacquard_derive::IntoStatic 44)] 45#[serde(rename_all = "camelCase")] 46pub struct CreateResult<'a> { 47 #[serde(borrow)] 48 pub cid: jacquard_common::types::string::Cid<'a>, 49 #[serde(borrow)] 50 pub uri: jacquard_common::types::string::AtUri<'a>, 51 #[serde(skip_serializing_if = "std::option::Option::is_none")] 52 #[serde(borrow)] 53 pub validation_status: std::option::Option<jacquard_common::CowStr<'a>>, 54} 55 56///Operation which deletes an existing record. 57#[jacquard_derive::lexicon] 58#[derive( 59 serde::Serialize, 60 serde::Deserialize, 61 Debug, 62 Clone, 63 PartialEq, 64 Eq, 65 jacquard_derive::IntoStatic 66)] 67#[serde(rename_all = "camelCase")] 68pub struct Delete<'a> { 69 #[serde(borrow)] 70 pub collection: jacquard_common::types::string::Nsid<'a>, 71 #[serde(borrow)] 72 pub rkey: jacquard_common::types::string::RecordKey< 73 jacquard_common::types::string::Rkey<'a>, 74 >, 75} 76 77#[jacquard_derive::lexicon] 78#[derive( 79 serde::Serialize, 80 serde::Deserialize, 81 Debug, 82 Clone, 83 PartialEq, 84 Eq, 85 jacquard_derive::IntoStatic 86)] 87#[serde(rename_all = "camelCase")] 88pub struct DeleteResult<'a> {} 89#[jacquard_derive::lexicon] 90#[derive( 91 serde::Serialize, 92 serde::Deserialize, 93 Debug, 94 Clone, 95 PartialEq, 96 Eq, 97 bon::Builder, 98 jacquard_derive::IntoStatic 99)] 100#[serde(rename_all = "camelCase")] 101#[builder(start_fn = new)] 102pub struct ApplyWrites<'a> { 103 ///The handle or DID of the repo (aka, current account). 104 #[serde(borrow)] 105 pub repo: jacquard_common::types::ident::AtIdentifier<'a>, 106 ///If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. 107 #[serde(skip_serializing_if = "std::option::Option::is_none")] 108 #[serde(borrow)] 109 pub swap_commit: std::option::Option<jacquard_common::types::string::Cid<'a>>, 110 ///Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons. 111 #[serde(skip_serializing_if = "std::option::Option::is_none")] 112 pub validate: std::option::Option<bool>, 113 #[serde(borrow)] 114 pub writes: Vec<ApplyWritesWritesItem<'a>>, 115 #[serde(flatten)] 116 #[serde(borrow)] 117 #[builder(default)] 118 pub extra_data: ::std::collections::BTreeMap< 119 ::jacquard_common::smol_str::SmolStr, 120 ::jacquard_common::types::value::Data<'a>, 121 >, 122} 123 124#[derive( 125 serde::Serialize, 126 serde::Deserialize, 127 Debug, 128 Clone, 129 PartialEq, 130 Eq, 131 jacquard_derive::IntoStatic 132)] 133#[serde(tag = "$type")] 134#[serde(bound(deserialize = "'de: 'a"))] 135pub enum ApplyWritesWritesItem<'a> { 136 #[serde(rename = "com.atproto.repo.applyWrites#create")] 137 Create(Box<crate::com_atproto::repo::apply_writes::Create<'a>>), 138 #[serde(rename = "com.atproto.repo.applyWrites#update")] 139 Update(Box<crate::com_atproto::repo::apply_writes::Update<'a>>), 140 #[serde(rename = "com.atproto.repo.applyWrites#delete")] 141 Delete(Box<crate::com_atproto::repo::apply_writes::Delete<'a>>), 142} 143 144#[jacquard_derive::lexicon] 145#[derive( 146 serde::Serialize, 147 serde::Deserialize, 148 Debug, 149 Clone, 150 PartialEq, 151 Eq, 152 jacquard_derive::IntoStatic 153)] 154#[serde(rename_all = "camelCase")] 155pub struct ApplyWritesOutput<'a> { 156 #[serde(skip_serializing_if = "std::option::Option::is_none")] 157 #[serde(borrow)] 158 pub commit: std::option::Option<crate::com_atproto::repo::CommitMeta<'a>>, 159 #[serde(skip_serializing_if = "std::option::Option::is_none")] 160 #[serde(borrow)] 161 pub results: std::option::Option<Vec<ApplyWritesOutputResultsItem<'a>>>, 162} 163 164#[derive( 165 serde::Serialize, 166 serde::Deserialize, 167 Debug, 168 Clone, 169 PartialEq, 170 Eq, 171 jacquard_derive::IntoStatic 172)] 173#[serde(tag = "$type")] 174#[serde(bound(deserialize = "'de: 'a"))] 175pub enum ApplyWritesOutputResultsItem<'a> { 176 #[serde(rename = "com.atproto.repo.applyWrites#createResult")] 177 CreateResult(Box<crate::com_atproto::repo::apply_writes::CreateResult<'a>>), 178 #[serde(rename = "com.atproto.repo.applyWrites#updateResult")] 179 UpdateResult(Box<crate::com_atproto::repo::apply_writes::UpdateResult<'a>>), 180 #[serde(rename = "com.atproto.repo.applyWrites#deleteResult")] 181 DeleteResult(Box<crate::com_atproto::repo::apply_writes::DeleteResult<'a>>), 182} 183 184#[jacquard_derive::open_union] 185#[derive( 186 serde::Serialize, 187 serde::Deserialize, 188 Debug, 189 Clone, 190 PartialEq, 191 Eq, 192 thiserror::Error, 193 miette::Diagnostic, 194 jacquard_derive::IntoStatic 195)] 196#[serde(tag = "error", content = "message")] 197#[serde(bound(deserialize = "'de: 'a"))] 198pub enum ApplyWritesError<'a> { 199 ///Indicates that the 'swapCommit' parameter did not match current commit. 200 #[serde(rename = "InvalidSwap")] 201 InvalidSwap(std::option::Option<String>), 202} 203 204impl std::fmt::Display for ApplyWritesError<'_> { 205 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 206 match self { 207 Self::InvalidSwap(msg) => { 208 write!(f, "InvalidSwap")?; 209 if let Some(msg) = msg { 210 write!(f, ": {}", msg)?; 211 } 212 Ok(()) 213 } 214 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 215 } 216 } 217} 218 219///Response type for 220///com.atproto.repo.applyWrites 221pub struct ApplyWritesResponse; 222impl jacquard_common::xrpc::XrpcResp for ApplyWritesResponse { 223 const NSID: &'static str = "com.atproto.repo.applyWrites"; 224 const ENCODING: &'static str = "application/json"; 225 type Output<'de> = ApplyWritesOutput<'de>; 226 type Err<'de> = ApplyWritesError<'de>; 227} 228 229impl<'a> jacquard_common::xrpc::XrpcRequest for ApplyWrites<'a> { 230 const NSID: &'static str = "com.atproto.repo.applyWrites"; 231 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 232 "application/json", 233 ); 234 type Response = ApplyWritesResponse; 235} 236 237///Endpoint type for 238///com.atproto.repo.applyWrites 239pub struct ApplyWritesRequest; 240impl jacquard_common::xrpc::XrpcEndpoint for ApplyWritesRequest { 241 const PATH: &'static str = "/xrpc/com.atproto.repo.applyWrites"; 242 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 243 "application/json", 244 ); 245 type Request<'de> = ApplyWrites<'de>; 246 type Response = ApplyWritesResponse; 247} 248 249///Operation which updates an existing record. 250#[jacquard_derive::lexicon] 251#[derive( 252 serde::Serialize, 253 serde::Deserialize, 254 Debug, 255 Clone, 256 PartialEq, 257 Eq, 258 jacquard_derive::IntoStatic 259)] 260#[serde(rename_all = "camelCase")] 261pub struct Update<'a> { 262 #[serde(borrow)] 263 pub collection: jacquard_common::types::string::Nsid<'a>, 264 #[serde(borrow)] 265 pub rkey: jacquard_common::types::string::RecordKey< 266 jacquard_common::types::string::Rkey<'a>, 267 >, 268 #[serde(borrow)] 269 pub value: jacquard_common::types::value::Data<'a>, 270} 271 272#[jacquard_derive::lexicon] 273#[derive( 274 serde::Serialize, 275 serde::Deserialize, 276 Debug, 277 Clone, 278 PartialEq, 279 Eq, 280 jacquard_derive::IntoStatic 281)] 282#[serde(rename_all = "camelCase")] 283pub struct UpdateResult<'a> { 284 #[serde(borrow)] 285 pub cid: jacquard_common::types::string::Cid<'a>, 286 #[serde(borrow)] 287 pub uri: jacquard_common::types::string::AtUri<'a>, 288 #[serde(skip_serializing_if = "std::option::Option::is_none")] 289 #[serde(borrow)] 290 pub validation_status: std::option::Option<jacquard_common::CowStr<'a>>, 291}