atproto blogging
at main 273 lines 8.3 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.getBlob 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 GetBlob<'a> { 19 #[serde(borrow)] 20 pub cid: jacquard_common::types::string::Cid<'a>, 21 #[serde(borrow)] 22 pub did: jacquard_common::types::string::Did<'a>, 23} 24 25pub mod get_blob_state { 26 27 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 28 #[allow(unused)] 29 use ::core::marker::PhantomData; 30 mod sealed { 31 pub trait Sealed {} 32 } 33 /// State trait tracking which required fields have been set 34 pub trait State: sealed::Sealed { 35 type Cid; 36 type Did; 37 } 38 /// Empty state - all required fields are unset 39 pub struct Empty(()); 40 impl sealed::Sealed for Empty {} 41 impl State for Empty { 42 type Cid = Unset; 43 type Did = Unset; 44 } 45 ///State transition - sets the `cid` field to Set 46 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>); 47 impl<S: State> sealed::Sealed for SetCid<S> {} 48 impl<S: State> State for SetCid<S> { 49 type Cid = Set<members::cid>; 50 type Did = S::Did; 51 } 52 ///State transition - sets the `did` field to Set 53 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>); 54 impl<S: State> sealed::Sealed for SetDid<S> {} 55 impl<S: State> State for SetDid<S> { 56 type Cid = S::Cid; 57 type Did = Set<members::did>; 58 } 59 /// Marker types for field names 60 #[allow(non_camel_case_types)] 61 pub mod members { 62 ///Marker type for the `cid` field 63 pub struct cid(()); 64 ///Marker type for the `did` field 65 pub struct did(()); 66 } 67} 68 69/// Builder for constructing an instance of this type 70pub struct GetBlobBuilder<'a, S: get_blob_state::State> { 71 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 72 __unsafe_private_named: ( 73 ::core::option::Option<jacquard_common::types::string::Cid<'a>>, 74 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 75 ), 76 _phantom: ::core::marker::PhantomData<&'a ()>, 77} 78 79impl<'a> GetBlob<'a> { 80 /// Create a new builder for this type 81 pub fn new() -> GetBlobBuilder<'a, get_blob_state::Empty> { 82 GetBlobBuilder::new() 83 } 84} 85 86impl<'a> GetBlobBuilder<'a, get_blob_state::Empty> { 87 /// Create a new builder with all fields unset 88 pub fn new() -> Self { 89 GetBlobBuilder { 90 _phantom_state: ::core::marker::PhantomData, 91 __unsafe_private_named: (None, None), 92 _phantom: ::core::marker::PhantomData, 93 } 94 } 95} 96 97impl<'a, S> GetBlobBuilder<'a, S> 98where 99 S: get_blob_state::State, 100 S::Cid: get_blob_state::IsUnset, 101{ 102 /// Set the `cid` field (required) 103 pub fn cid( 104 mut self, 105 value: impl Into<jacquard_common::types::string::Cid<'a>>, 106 ) -> GetBlobBuilder<'a, get_blob_state::SetCid<S>> { 107 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 108 GetBlobBuilder { 109 _phantom_state: ::core::marker::PhantomData, 110 __unsafe_private_named: self.__unsafe_private_named, 111 _phantom: ::core::marker::PhantomData, 112 } 113 } 114} 115 116impl<'a, S> GetBlobBuilder<'a, S> 117where 118 S: get_blob_state::State, 119 S::Did: get_blob_state::IsUnset, 120{ 121 /// Set the `did` field (required) 122 pub fn did( 123 mut self, 124 value: impl Into<jacquard_common::types::string::Did<'a>>, 125 ) -> GetBlobBuilder<'a, get_blob_state::SetDid<S>> { 126 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 127 GetBlobBuilder { 128 _phantom_state: ::core::marker::PhantomData, 129 __unsafe_private_named: self.__unsafe_private_named, 130 _phantom: ::core::marker::PhantomData, 131 } 132 } 133} 134 135impl<'a, S> GetBlobBuilder<'a, S> 136where 137 S: get_blob_state::State, 138 S::Cid: get_blob_state::IsSet, 139 S::Did: get_blob_state::IsSet, 140{ 141 /// Build the final struct 142 pub fn build(self) -> GetBlob<'a> { 143 GetBlob { 144 cid: self.__unsafe_private_named.0.unwrap(), 145 did: self.__unsafe_private_named.1.unwrap(), 146 } 147 } 148} 149 150#[derive( 151 serde::Serialize, 152 serde::Deserialize, 153 Debug, 154 Clone, 155 PartialEq, 156 Eq, 157 jacquard_derive::IntoStatic 158)] 159#[serde(rename_all = "camelCase")] 160pub struct GetBlobOutput { 161 pub body: bytes::Bytes, 162} 163 164#[jacquard_derive::open_union] 165#[derive( 166 serde::Serialize, 167 serde::Deserialize, 168 Debug, 169 Clone, 170 PartialEq, 171 Eq, 172 thiserror::Error, 173 miette::Diagnostic, 174 jacquard_derive::IntoStatic 175)] 176#[serde(tag = "error", content = "message")] 177#[serde(bound(deserialize = "'de: 'a"))] 178pub enum GetBlobError<'a> { 179 #[serde(rename = "BlobNotFound")] 180 BlobNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 181 #[serde(rename = "RepoNotFound")] 182 RepoNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 183 #[serde(rename = "RepoTakendown")] 184 RepoTakendown(std::option::Option<jacquard_common::CowStr<'a>>), 185 #[serde(rename = "RepoSuspended")] 186 RepoSuspended(std::option::Option<jacquard_common::CowStr<'a>>), 187 #[serde(rename = "RepoDeactivated")] 188 RepoDeactivated(std::option::Option<jacquard_common::CowStr<'a>>), 189} 190 191impl core::fmt::Display for GetBlobError<'_> { 192 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 193 match self { 194 Self::BlobNotFound(msg) => { 195 write!(f, "BlobNotFound")?; 196 if let Some(msg) = msg { 197 write!(f, ": {}", msg)?; 198 } 199 Ok(()) 200 } 201 Self::RepoNotFound(msg) => { 202 write!(f, "RepoNotFound")?; 203 if let Some(msg) = msg { 204 write!(f, ": {}", msg)?; 205 } 206 Ok(()) 207 } 208 Self::RepoTakendown(msg) => { 209 write!(f, "RepoTakendown")?; 210 if let Some(msg) = msg { 211 write!(f, ": {}", msg)?; 212 } 213 Ok(()) 214 } 215 Self::RepoSuspended(msg) => { 216 write!(f, "RepoSuspended")?; 217 if let Some(msg) = msg { 218 write!(f, ": {}", msg)?; 219 } 220 Ok(()) 221 } 222 Self::RepoDeactivated(msg) => { 223 write!(f, "RepoDeactivated")?; 224 if let Some(msg) = msg { 225 write!(f, ": {}", msg)?; 226 } 227 Ok(()) 228 } 229 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 230 } 231 } 232} 233 234/// Response type for 235///com.atproto.sync.getBlob 236pub struct GetBlobResponse; 237impl jacquard_common::xrpc::XrpcResp for GetBlobResponse { 238 const NSID: &'static str = "com.atproto.sync.getBlob"; 239 const ENCODING: &'static str = "*/*"; 240 type Output<'de> = GetBlobOutput; 241 type Err<'de> = GetBlobError<'de>; 242 fn encode_output( 243 output: &Self::Output<'_>, 244 ) -> Result<Vec<u8>, jacquard_common::xrpc::EncodeError> { 245 Ok(output.body.to_vec()) 246 } 247 fn decode_output<'de>( 248 body: &'de [u8], 249 ) -> Result<Self::Output<'de>, jacquard_common::error::DecodeError> 250 where 251 Self::Output<'de>: serde::Deserialize<'de>, 252 { 253 Ok(GetBlobOutput { 254 body: bytes::Bytes::copy_from_slice(body), 255 }) 256 } 257} 258 259impl<'a> jacquard_common::xrpc::XrpcRequest for GetBlob<'a> { 260 const NSID: &'static str = "com.atproto.sync.getBlob"; 261 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 262 type Response = GetBlobResponse; 263} 264 265/// Endpoint type for 266///com.atproto.sync.getBlob 267pub struct GetBlobRequest; 268impl jacquard_common::xrpc::XrpcEndpoint for GetBlobRequest { 269 const PATH: &'static str = "/xrpc/com.atproto.sync.getBlob"; 270 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 271 type Request<'de> = GetBlob<'de>; 272 type Response = GetBlobResponse; 273}