A better Rust ATProto crate
at lifetimes 7.8 kB view raw
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<jacquard_common::types::value::Data<'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#[jacquard_derive::lexicon] 125#[derive( 126 serde::Serialize, 127 serde::Deserialize, 128 Debug, 129 Clone, 130 PartialEq, 131 Eq, 132 jacquard_derive::IntoStatic 133)] 134#[serde(rename_all = "camelCase")] 135pub struct ApplyWritesOutput<'a> { 136 #[serde(skip_serializing_if = "std::option::Option::is_none")] 137 #[serde(borrow)] 138 pub commit: std::option::Option<crate::com_atproto::repo::CommitMeta<'a>>, 139 #[serde(skip_serializing_if = "std::option::Option::is_none")] 140 #[serde(borrow)] 141 pub results: std::option::Option<Vec<jacquard_common::types::value::Data<'a>>>, 142} 143 144#[jacquard_derive::open_union] 145#[derive( 146 serde::Serialize, 147 serde::Deserialize, 148 Debug, 149 Clone, 150 PartialEq, 151 Eq, 152 thiserror::Error, 153 miette::Diagnostic 154)] 155#[serde(tag = "error", content = "message")] 156#[serde(bound(deserialize = "'de: 'a"))] 157pub enum ApplyWritesError<'a> { 158 ///Indicates that the 'swapCommit' parameter did not match current commit. 159 #[serde(rename = "InvalidSwap")] 160 InvalidSwap(std::option::Option<String>), 161} 162 163impl std::fmt::Display for ApplyWritesError<'_> { 164 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 165 match self { 166 Self::InvalidSwap(msg) => { 167 write!(f, "InvalidSwap")?; 168 if let Some(msg) = msg { 169 write!(f, ": {}", msg)?; 170 } 171 Ok(()) 172 } 173 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 174 } 175 } 176} 177 178impl jacquard_common::IntoStatic for ApplyWritesError<'_> { 179 type Output = ApplyWritesError<'static>; 180 fn into_static(self) -> Self::Output { 181 match self { 182 ApplyWritesError::InvalidSwap(v) => { 183 ApplyWritesError::InvalidSwap(v.into_static()) 184 } 185 ApplyWritesError::Unknown(v) => ApplyWritesError::Unknown(v.into_static()), 186 } 187 } 188} 189 190///Response type for 191///com.atproto.repo.applyWrites 192pub struct ApplyWritesResponse; 193impl jacquard_common::xrpc::XrpcResp for ApplyWritesResponse { 194 const NSID: &'static str = "com.atproto.repo.applyWrites"; 195 const ENCODING: &'static str = "application/json"; 196 type Output<'de> = ApplyWritesOutput<'de>; 197 type Err<'de> = ApplyWritesError<'de>; 198} 199 200impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for ApplyWrites<'de> { 201 const NSID: &'static str = "com.atproto.repo.applyWrites"; 202 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 203 "application/json", 204 ); 205 type Response = ApplyWritesResponse; 206} 207 208///Endpoint type for 209///com.atproto.repo.applyWrites 210pub struct ApplyWritesRequest; 211impl jacquard_common::xrpc::XrpcEndpoint for ApplyWritesRequest { 212 const PATH: &'static str = "/xrpc/com.atproto.repo.applyWrites"; 213 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 214 "application/json", 215 ); 216 type Request<'de> = ApplyWrites<'de>; 217 type Response = ApplyWritesResponse; 218} 219 220///Operation which updates an existing record. 221#[jacquard_derive::lexicon] 222#[derive( 223 serde::Serialize, 224 serde::Deserialize, 225 Debug, 226 Clone, 227 PartialEq, 228 Eq, 229 jacquard_derive::IntoStatic 230)] 231#[serde(rename_all = "camelCase")] 232pub struct Update<'a> { 233 #[serde(borrow)] 234 pub collection: jacquard_common::types::string::Nsid<'a>, 235 #[serde(borrow)] 236 pub rkey: jacquard_common::types::string::RecordKey< 237 jacquard_common::types::string::Rkey<'a>, 238 >, 239 #[serde(borrow)] 240 pub value: jacquard_common::types::value::Data<'a>, 241} 242 243#[jacquard_derive::lexicon] 244#[derive( 245 serde::Serialize, 246 serde::Deserialize, 247 Debug, 248 Clone, 249 PartialEq, 250 Eq, 251 jacquard_derive::IntoStatic 252)] 253#[serde(rename_all = "camelCase")] 254pub struct UpdateResult<'a> { 255 #[serde(borrow)] 256 pub cid: jacquard_common::types::string::Cid<'a>, 257 #[serde(borrow)] 258 pub uri: jacquard_common::types::string::AtUri<'a>, 259 #[serde(skip_serializing_if = "std::option::Option::is_none")] 260 #[serde(borrow)] 261 pub validation_status: std::option::Option<jacquard_common::CowStr<'a>>, 262}