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