A better Rust ATProto crate
at oauth 4.9 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: app.bsky.unspecced.initAgeAssurance 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 bon::Builder 17)] 18#[serde(rename_all = "camelCase")] 19#[builder(start_fn = new)] 20pub struct InitAgeAssurance<'a> { 21 ///An ISO 3166-1 alpha-2 code of the user's location. 22 #[serde(borrow)] 23 #[builder(into)] 24 pub country_code: jacquard_common::CowStr<'a>, 25 ///The user's email address to receive assurance instructions. 26 #[serde(borrow)] 27 #[builder(into)] 28 pub email: jacquard_common::CowStr<'a>, 29 ///The user's preferred language for communication during the assurance process. 30 #[serde(borrow)] 31 #[builder(into)] 32 pub language: jacquard_common::CowStr<'a>, 33 #[serde(flatten)] 34 #[serde(borrow)] 35 #[builder(default)] 36 pub extra_data: ::std::collections::BTreeMap< 37 ::jacquard_common::smol_str::SmolStr, 38 ::jacquard_common::types::value::Data<'a>, 39 >, 40} 41 42impl jacquard_common::IntoStatic for InitAgeAssurance<'_> { 43 type Output = InitAgeAssurance<'static>; 44 fn into_static(self) -> Self::Output { 45 InitAgeAssurance { 46 country_code: self.country_code.into_static(), 47 email: self.email.into_static(), 48 language: self.language.into_static(), 49 extra_data: self.extra_data.into_static(), 50 } 51 } 52} 53 54#[jacquard_derive::lexicon] 55#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 56#[serde(rename_all = "camelCase")] 57pub struct InitAgeAssuranceOutput<'a> { 58 #[serde(flatten)] 59 #[serde(borrow)] 60 pub value: crate::app_bsky::unspecced::AgeAssuranceState<'a>, 61} 62 63impl jacquard_common::IntoStatic for InitAgeAssuranceOutput<'_> { 64 type Output = InitAgeAssuranceOutput<'static>; 65 fn into_static(self) -> Self::Output { 66 InitAgeAssuranceOutput { 67 value: self.value.into_static(), 68 extra_data: self.extra_data.into_static(), 69 } 70 } 71} 72 73#[jacquard_derive::open_union] 74#[derive( 75 serde::Serialize, 76 serde::Deserialize, 77 Debug, 78 Clone, 79 PartialEq, 80 Eq, 81 thiserror::Error, 82 miette::Diagnostic 83)] 84#[serde(tag = "error", content = "message")] 85#[serde(bound(deserialize = "'de: 'a"))] 86pub enum InitAgeAssuranceError<'a> { 87 #[serde(rename = "InvalidEmail")] 88 InvalidEmail(std::option::Option<String>), 89 #[serde(rename = "DidTooLong")] 90 DidTooLong(std::option::Option<String>), 91 #[serde(rename = "InvalidInitiation")] 92 InvalidInitiation(std::option::Option<String>), 93} 94 95impl std::fmt::Display for InitAgeAssuranceError<'_> { 96 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 97 match self { 98 Self::InvalidEmail(msg) => { 99 write!(f, "InvalidEmail")?; 100 if let Some(msg) = msg { 101 write!(f, ": {}", msg)?; 102 } 103 Ok(()) 104 } 105 Self::DidTooLong(msg) => { 106 write!(f, "DidTooLong")?; 107 if let Some(msg) = msg { 108 write!(f, ": {}", msg)?; 109 } 110 Ok(()) 111 } 112 Self::InvalidInitiation(msg) => { 113 write!(f, "InvalidInitiation")?; 114 if let Some(msg) = msg { 115 write!(f, ": {}", msg)?; 116 } 117 Ok(()) 118 } 119 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 120 } 121 } 122} 123 124impl jacquard_common::IntoStatic for InitAgeAssuranceError<'_> { 125 type Output = InitAgeAssuranceError<'static>; 126 fn into_static(self) -> Self::Output { 127 match self { 128 InitAgeAssuranceError::InvalidEmail(v) => { 129 InitAgeAssuranceError::InvalidEmail(v.into_static()) 130 } 131 InitAgeAssuranceError::DidTooLong(v) => { 132 InitAgeAssuranceError::DidTooLong(v.into_static()) 133 } 134 InitAgeAssuranceError::InvalidInitiation(v) => { 135 InitAgeAssuranceError::InvalidInitiation(v.into_static()) 136 } 137 InitAgeAssuranceError::Unknown(v) => { 138 InitAgeAssuranceError::Unknown(v.into_static()) 139 } 140 } 141 } 142} 143 144impl jacquard_common::types::xrpc::XrpcRequest for InitAgeAssurance<'_> { 145 const NSID: &'static str = "app.bsky.unspecced.initAgeAssurance"; 146 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Procedure( 147 "application/json", 148 ); 149 const OUTPUT_ENCODING: &'static str = "application/json"; 150 type Output<'de> = InitAgeAssuranceOutput<'de>; 151 type Err<'de> = InitAgeAssuranceError<'de>; 152}