atproto blogging
at main 231 lines 7.2 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.server.getServiceAuth 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 GetServiceAuth<'a> { 19 #[serde(borrow)] 20 pub aud: jacquard_common::types::string::Did<'a>, 21 #[serde(skip_serializing_if = "std::option::Option::is_none")] 22 pub exp: std::option::Option<i64>, 23 #[serde(skip_serializing_if = "std::option::Option::is_none")] 24 #[serde(borrow)] 25 pub lxm: std::option::Option<jacquard_common::types::string::Nsid<'a>>, 26} 27 28pub mod get_service_auth_state { 29 30 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 31 #[allow(unused)] 32 use ::core::marker::PhantomData; 33 mod sealed { 34 pub trait Sealed {} 35 } 36 /// State trait tracking which required fields have been set 37 pub trait State: sealed::Sealed { 38 type Aud; 39 } 40 /// Empty state - all required fields are unset 41 pub struct Empty(()); 42 impl sealed::Sealed for Empty {} 43 impl State for Empty { 44 type Aud = Unset; 45 } 46 ///State transition - sets the `aud` field to Set 47 pub struct SetAud<S: State = Empty>(PhantomData<fn() -> S>); 48 impl<S: State> sealed::Sealed for SetAud<S> {} 49 impl<S: State> State for SetAud<S> { 50 type Aud = Set<members::aud>; 51 } 52 /// Marker types for field names 53 #[allow(non_camel_case_types)] 54 pub mod members { 55 ///Marker type for the `aud` field 56 pub struct aud(()); 57 } 58} 59 60/// Builder for constructing an instance of this type 61pub struct GetServiceAuthBuilder<'a, S: get_service_auth_state::State> { 62 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 63 __unsafe_private_named: ( 64 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 65 ::core::option::Option<i64>, 66 ::core::option::Option<jacquard_common::types::string::Nsid<'a>>, 67 ), 68 _phantom: ::core::marker::PhantomData<&'a ()>, 69} 70 71impl<'a> GetServiceAuth<'a> { 72 /// Create a new builder for this type 73 pub fn new() -> GetServiceAuthBuilder<'a, get_service_auth_state::Empty> { 74 GetServiceAuthBuilder::new() 75 } 76} 77 78impl<'a> GetServiceAuthBuilder<'a, get_service_auth_state::Empty> { 79 /// Create a new builder with all fields unset 80 pub fn new() -> Self { 81 GetServiceAuthBuilder { 82 _phantom_state: ::core::marker::PhantomData, 83 __unsafe_private_named: (None, None, None), 84 _phantom: ::core::marker::PhantomData, 85 } 86 } 87} 88 89impl<'a, S> GetServiceAuthBuilder<'a, S> 90where 91 S: get_service_auth_state::State, 92 S::Aud: get_service_auth_state::IsUnset, 93{ 94 /// Set the `aud` field (required) 95 pub fn aud( 96 mut self, 97 value: impl Into<jacquard_common::types::string::Did<'a>>, 98 ) -> GetServiceAuthBuilder<'a, get_service_auth_state::SetAud<S>> { 99 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 100 GetServiceAuthBuilder { 101 _phantom_state: ::core::marker::PhantomData, 102 __unsafe_private_named: self.__unsafe_private_named, 103 _phantom: ::core::marker::PhantomData, 104 } 105 } 106} 107 108impl<'a, S: get_service_auth_state::State> GetServiceAuthBuilder<'a, S> { 109 /// Set the `exp` field (optional) 110 pub fn exp(mut self, value: impl Into<Option<i64>>) -> Self { 111 self.__unsafe_private_named.1 = value.into(); 112 self 113 } 114 /// Set the `exp` field to an Option value (optional) 115 pub fn maybe_exp(mut self, value: Option<i64>) -> Self { 116 self.__unsafe_private_named.1 = value; 117 self 118 } 119} 120 121impl<'a, S: get_service_auth_state::State> GetServiceAuthBuilder<'a, S> { 122 /// Set the `lxm` field (optional) 123 pub fn lxm( 124 mut self, 125 value: impl Into<Option<jacquard_common::types::string::Nsid<'a>>>, 126 ) -> Self { 127 self.__unsafe_private_named.2 = value.into(); 128 self 129 } 130 /// Set the `lxm` field to an Option value (optional) 131 pub fn maybe_lxm( 132 mut self, 133 value: Option<jacquard_common::types::string::Nsid<'a>>, 134 ) -> Self { 135 self.__unsafe_private_named.2 = value; 136 self 137 } 138} 139 140impl<'a, S> GetServiceAuthBuilder<'a, S> 141where 142 S: get_service_auth_state::State, 143 S::Aud: get_service_auth_state::IsSet, 144{ 145 /// Build the final struct 146 pub fn build(self) -> GetServiceAuth<'a> { 147 GetServiceAuth { 148 aud: self.__unsafe_private_named.0.unwrap(), 149 exp: self.__unsafe_private_named.1, 150 lxm: self.__unsafe_private_named.2, 151 } 152 } 153} 154 155#[jacquard_derive::lexicon] 156#[derive( 157 serde::Serialize, 158 serde::Deserialize, 159 Debug, 160 Clone, 161 PartialEq, 162 Eq, 163 jacquard_derive::IntoStatic, 164 Default 165)] 166#[serde(rename_all = "camelCase")] 167pub struct GetServiceAuthOutput<'a> { 168 #[serde(borrow)] 169 pub token: jacquard_common::CowStr<'a>, 170} 171 172#[jacquard_derive::open_union] 173#[derive( 174 serde::Serialize, 175 serde::Deserialize, 176 Debug, 177 Clone, 178 PartialEq, 179 Eq, 180 thiserror::Error, 181 miette::Diagnostic, 182 jacquard_derive::IntoStatic 183)] 184#[serde(tag = "error", content = "message")] 185#[serde(bound(deserialize = "'de: 'a"))] 186pub enum GetServiceAuthError<'a> { 187 /// Indicates that the requested expiration date is not a valid. May be in the past or may be reliant on the requested scopes. 188 #[serde(rename = "BadExpiration")] 189 BadExpiration(std::option::Option<jacquard_common::CowStr<'a>>), 190} 191 192impl core::fmt::Display for GetServiceAuthError<'_> { 193 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 194 match self { 195 Self::BadExpiration(msg) => { 196 write!(f, "BadExpiration")?; 197 if let Some(msg) = msg { 198 write!(f, ": {}", msg)?; 199 } 200 Ok(()) 201 } 202 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 203 } 204 } 205} 206 207/// Response type for 208///com.atproto.server.getServiceAuth 209pub struct GetServiceAuthResponse; 210impl jacquard_common::xrpc::XrpcResp for GetServiceAuthResponse { 211 const NSID: &'static str = "com.atproto.server.getServiceAuth"; 212 const ENCODING: &'static str = "application/json"; 213 type Output<'de> = GetServiceAuthOutput<'de>; 214 type Err<'de> = GetServiceAuthError<'de>; 215} 216 217impl<'a> jacquard_common::xrpc::XrpcRequest for GetServiceAuth<'a> { 218 const NSID: &'static str = "com.atproto.server.getServiceAuth"; 219 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 220 type Response = GetServiceAuthResponse; 221} 222 223/// Endpoint type for 224///com.atproto.server.getServiceAuth 225pub struct GetServiceAuthRequest; 226impl jacquard_common::xrpc::XrpcEndpoint for GetServiceAuthRequest { 227 const PATH: &'static str = "/xrpc/com.atproto.server.getServiceAuth"; 228 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 229 type Request<'de> = GetServiceAuth<'de>; 230 type Response = GetServiceAuthResponse; 231}