A better Rust ATProto crate
at oauth 3.5 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 bon::Builder 16)] 17#[builder(start_fn = new)] 18#[serde(rename_all = "camelCase")] 19pub struct GetServiceAuth<'a> { 20 #[serde(borrow)] 21 pub aud: jacquard_common::types::string::Did<'a>, 22 #[serde(skip_serializing_if = "std::option::Option::is_none")] 23 pub exp: std::option::Option<i64>, 24 #[serde(skip_serializing_if = "std::option::Option::is_none")] 25 #[serde(borrow)] 26 pub lxm: std::option::Option<jacquard_common::types::string::Nsid<'a>>, 27} 28 29impl jacquard_common::IntoStatic for GetServiceAuth<'_> { 30 type Output = GetServiceAuth<'static>; 31 fn into_static(self) -> Self::Output { 32 GetServiceAuth { 33 aud: self.aud.into_static(), 34 exp: self.exp.into_static(), 35 lxm: self.lxm.into_static(), 36 } 37 } 38} 39 40#[jacquard_derive::lexicon] 41#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 42#[serde(rename_all = "camelCase")] 43pub struct GetServiceAuthOutput<'a> { 44 #[serde(borrow)] 45 pub token: jacquard_common::CowStr<'a>, 46} 47 48impl jacquard_common::IntoStatic for GetServiceAuthOutput<'_> { 49 type Output = GetServiceAuthOutput<'static>; 50 fn into_static(self) -> Self::Output { 51 GetServiceAuthOutput { 52 token: self.token.into_static(), 53 extra_data: self.extra_data.into_static(), 54 } 55 } 56} 57 58#[jacquard_derive::open_union] 59#[derive( 60 serde::Serialize, 61 serde::Deserialize, 62 Debug, 63 Clone, 64 PartialEq, 65 Eq, 66 thiserror::Error, 67 miette::Diagnostic 68)] 69#[serde(tag = "error", content = "message")] 70#[serde(bound(deserialize = "'de: 'a"))] 71pub enum GetServiceAuthError<'a> { 72 ///Indicates that the requested expiration date is not a valid. May be in the past or may be reliant on the requested scopes. 73 #[serde(rename = "BadExpiration")] 74 BadExpiration(std::option::Option<String>), 75} 76 77impl std::fmt::Display for GetServiceAuthError<'_> { 78 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 79 match self { 80 Self::BadExpiration(msg) => { 81 write!(f, "BadExpiration")?; 82 if let Some(msg) = msg { 83 write!(f, ": {}", msg)?; 84 } 85 Ok(()) 86 } 87 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 88 } 89 } 90} 91 92impl jacquard_common::IntoStatic for GetServiceAuthError<'_> { 93 type Output = GetServiceAuthError<'static>; 94 fn into_static(self) -> Self::Output { 95 match self { 96 GetServiceAuthError::BadExpiration(v) => { 97 GetServiceAuthError::BadExpiration(v.into_static()) 98 } 99 GetServiceAuthError::Unknown(v) => { 100 GetServiceAuthError::Unknown(v.into_static()) 101 } 102 } 103 } 104} 105 106impl jacquard_common::types::xrpc::XrpcRequest for GetServiceAuth<'_> { 107 const NSID: &'static str = "com.atproto.server.getServiceAuth"; 108 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query; 109 const OUTPUT_ENCODING: &'static str = "application/json"; 110 type Output<'de> = GetServiceAuthOutput<'de>; 111 type Err<'de> = GetServiceAuthError<'de>; 112}