atproto blogging
at main 198 lines 6.3 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.server.createInviteCode 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 jacquard_derive::IntoStatic 17)] 18#[serde(rename_all = "camelCase")] 19pub struct CreateInviteCode<'a> { 20 #[serde(skip_serializing_if = "std::option::Option::is_none")] 21 #[serde(borrow)] 22 pub for_account: std::option::Option<jacquard_common::types::string::Did<'a>>, 23 pub use_count: i64, 24} 25 26pub mod create_invite_code_state { 27 28 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 29 #[allow(unused)] 30 use ::core::marker::PhantomData; 31 mod sealed { 32 pub trait Sealed {} 33 } 34 /// State trait tracking which required fields have been set 35 pub trait State: sealed::Sealed { 36 type UseCount; 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 UseCount = Unset; 43 } 44 ///State transition - sets the `use_count` field to Set 45 pub struct SetUseCount<S: State = Empty>(PhantomData<fn() -> S>); 46 impl<S: State> sealed::Sealed for SetUseCount<S> {} 47 impl<S: State> State for SetUseCount<S> { 48 type UseCount = Set<members::use_count>; 49 } 50 /// Marker types for field names 51 #[allow(non_camel_case_types)] 52 pub mod members { 53 ///Marker type for the `use_count` field 54 pub struct use_count(()); 55 } 56} 57 58/// Builder for constructing an instance of this type 59pub struct CreateInviteCodeBuilder<'a, S: create_invite_code_state::State> { 60 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 61 __unsafe_private_named: ( 62 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 63 ::core::option::Option<i64>, 64 ), 65 _phantom: ::core::marker::PhantomData<&'a ()>, 66} 67 68impl<'a> CreateInviteCode<'a> { 69 /// Create a new builder for this type 70 pub fn new() -> CreateInviteCodeBuilder<'a, create_invite_code_state::Empty> { 71 CreateInviteCodeBuilder::new() 72 } 73} 74 75impl<'a> CreateInviteCodeBuilder<'a, create_invite_code_state::Empty> { 76 /// Create a new builder with all fields unset 77 pub fn new() -> Self { 78 CreateInviteCodeBuilder { 79 _phantom_state: ::core::marker::PhantomData, 80 __unsafe_private_named: (None, None), 81 _phantom: ::core::marker::PhantomData, 82 } 83 } 84} 85 86impl<'a, S: create_invite_code_state::State> CreateInviteCodeBuilder<'a, S> { 87 /// Set the `forAccount` field (optional) 88 pub fn for_account( 89 mut self, 90 value: impl Into<Option<jacquard_common::types::string::Did<'a>>>, 91 ) -> Self { 92 self.__unsafe_private_named.0 = value.into(); 93 self 94 } 95 /// Set the `forAccount` field to an Option value (optional) 96 pub fn maybe_for_account( 97 mut self, 98 value: Option<jacquard_common::types::string::Did<'a>>, 99 ) -> Self { 100 self.__unsafe_private_named.0 = value; 101 self 102 } 103} 104 105impl<'a, S> CreateInviteCodeBuilder<'a, S> 106where 107 S: create_invite_code_state::State, 108 S::UseCount: create_invite_code_state::IsUnset, 109{ 110 /// Set the `useCount` field (required) 111 pub fn use_count( 112 mut self, 113 value: impl Into<i64>, 114 ) -> CreateInviteCodeBuilder<'a, create_invite_code_state::SetUseCount<S>> { 115 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 116 CreateInviteCodeBuilder { 117 _phantom_state: ::core::marker::PhantomData, 118 __unsafe_private_named: self.__unsafe_private_named, 119 _phantom: ::core::marker::PhantomData, 120 } 121 } 122} 123 124impl<'a, S> CreateInviteCodeBuilder<'a, S> 125where 126 S: create_invite_code_state::State, 127 S::UseCount: create_invite_code_state::IsSet, 128{ 129 /// Build the final struct 130 pub fn build(self) -> CreateInviteCode<'a> { 131 CreateInviteCode { 132 for_account: self.__unsafe_private_named.0, 133 use_count: self.__unsafe_private_named.1.unwrap(), 134 extra_data: Default::default(), 135 } 136 } 137 /// Build the final struct with custom extra_data 138 pub fn build_with_data( 139 self, 140 extra_data: std::collections::BTreeMap< 141 jacquard_common::smol_str::SmolStr, 142 jacquard_common::types::value::Data<'a>, 143 >, 144 ) -> CreateInviteCode<'a> { 145 CreateInviteCode { 146 for_account: self.__unsafe_private_named.0, 147 use_count: self.__unsafe_private_named.1.unwrap(), 148 extra_data: Some(extra_data), 149 } 150 } 151} 152 153#[jacquard_derive::lexicon] 154#[derive( 155 serde::Serialize, 156 serde::Deserialize, 157 Debug, 158 Clone, 159 PartialEq, 160 Eq, 161 jacquard_derive::IntoStatic, 162 Default 163)] 164#[serde(rename_all = "camelCase")] 165pub struct CreateInviteCodeOutput<'a> { 166 #[serde(borrow)] 167 pub code: jacquard_common::CowStr<'a>, 168} 169 170/// Response type for 171///com.atproto.server.createInviteCode 172pub struct CreateInviteCodeResponse; 173impl jacquard_common::xrpc::XrpcResp for CreateInviteCodeResponse { 174 const NSID: &'static str = "com.atproto.server.createInviteCode"; 175 const ENCODING: &'static str = "application/json"; 176 type Output<'de> = CreateInviteCodeOutput<'de>; 177 type Err<'de> = jacquard_common::xrpc::GenericError<'de>; 178} 179 180impl<'a> jacquard_common::xrpc::XrpcRequest for CreateInviteCode<'a> { 181 const NSID: &'static str = "com.atproto.server.createInviteCode"; 182 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 183 "application/json", 184 ); 185 type Response = CreateInviteCodeResponse; 186} 187 188/// Endpoint type for 189///com.atproto.server.createInviteCode 190pub struct CreateInviteCodeRequest; 191impl jacquard_common::xrpc::XrpcEndpoint for CreateInviteCodeRequest { 192 const PATH: &'static str = "/xrpc/com.atproto.server.createInviteCode"; 193 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 194 "application/json", 195 ); 196 type Request<'de> = CreateInviteCode<'de>; 197 type Response = CreateInviteCodeResponse; 198}