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