atproto blogging
at main 295 lines 8.9 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: tools.ozone.setting.removeOptions 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 RemoveOptions<'a> { 20 #[serde(borrow)] 21 pub keys: Vec<jacquard_common::types::string::Nsid<'a>>, 22 #[serde(borrow)] 23 pub scope: RemoveOptionsScope<'a>, 24} 25 26pub mod remove_options_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 Keys; 37 type Scope; 38 } 39 /// Empty state - all required fields are unset 40 pub struct Empty(()); 41 impl sealed::Sealed for Empty {} 42 impl State for Empty { 43 type Keys = Unset; 44 type Scope = Unset; 45 } 46 ///State transition - sets the `keys` field to Set 47 pub struct SetKeys<S: State = Empty>(PhantomData<fn() -> S>); 48 impl<S: State> sealed::Sealed for SetKeys<S> {} 49 impl<S: State> State for SetKeys<S> { 50 type Keys = Set<members::keys>; 51 type Scope = S::Scope; 52 } 53 ///State transition - sets the `scope` field to Set 54 pub struct SetScope<S: State = Empty>(PhantomData<fn() -> S>); 55 impl<S: State> sealed::Sealed for SetScope<S> {} 56 impl<S: State> State for SetScope<S> { 57 type Keys = S::Keys; 58 type Scope = Set<members::scope>; 59 } 60 /// Marker types for field names 61 #[allow(non_camel_case_types)] 62 pub mod members { 63 ///Marker type for the `keys` field 64 pub struct keys(()); 65 ///Marker type for the `scope` field 66 pub struct scope(()); 67 } 68} 69 70/// Builder for constructing an instance of this type 71pub struct RemoveOptionsBuilder<'a, S: remove_options_state::State> { 72 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 73 __unsafe_private_named: ( 74 ::core::option::Option<Vec<jacquard_common::types::string::Nsid<'a>>>, 75 ::core::option::Option<RemoveOptionsScope<'a>>, 76 ), 77 _phantom: ::core::marker::PhantomData<&'a ()>, 78} 79 80impl<'a> RemoveOptions<'a> { 81 /// Create a new builder for this type 82 pub fn new() -> RemoveOptionsBuilder<'a, remove_options_state::Empty> { 83 RemoveOptionsBuilder::new() 84 } 85} 86 87impl<'a> RemoveOptionsBuilder<'a, remove_options_state::Empty> { 88 /// Create a new builder with all fields unset 89 pub fn new() -> Self { 90 RemoveOptionsBuilder { 91 _phantom_state: ::core::marker::PhantomData, 92 __unsafe_private_named: (None, None), 93 _phantom: ::core::marker::PhantomData, 94 } 95 } 96} 97 98impl<'a, S> RemoveOptionsBuilder<'a, S> 99where 100 S: remove_options_state::State, 101 S::Keys: remove_options_state::IsUnset, 102{ 103 /// Set the `keys` field (required) 104 pub fn keys( 105 mut self, 106 value: impl Into<Vec<jacquard_common::types::string::Nsid<'a>>>, 107 ) -> RemoveOptionsBuilder<'a, remove_options_state::SetKeys<S>> { 108 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 109 RemoveOptionsBuilder { 110 _phantom_state: ::core::marker::PhantomData, 111 __unsafe_private_named: self.__unsafe_private_named, 112 _phantom: ::core::marker::PhantomData, 113 } 114 } 115} 116 117impl<'a, S> RemoveOptionsBuilder<'a, S> 118where 119 S: remove_options_state::State, 120 S::Scope: remove_options_state::IsUnset, 121{ 122 /// Set the `scope` field (required) 123 pub fn scope( 124 mut self, 125 value: impl Into<RemoveOptionsScope<'a>>, 126 ) -> RemoveOptionsBuilder<'a, remove_options_state::SetScope<S>> { 127 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 128 RemoveOptionsBuilder { 129 _phantom_state: ::core::marker::PhantomData, 130 __unsafe_private_named: self.__unsafe_private_named, 131 _phantom: ::core::marker::PhantomData, 132 } 133 } 134} 135 136impl<'a, S> RemoveOptionsBuilder<'a, S> 137where 138 S: remove_options_state::State, 139 S::Keys: remove_options_state::IsSet, 140 S::Scope: remove_options_state::IsSet, 141{ 142 /// Build the final struct 143 pub fn build(self) -> RemoveOptions<'a> { 144 RemoveOptions { 145 keys: self.__unsafe_private_named.0.unwrap(), 146 scope: self.__unsafe_private_named.1.unwrap(), 147 extra_data: Default::default(), 148 } 149 } 150 /// Build the final struct with custom extra_data 151 pub fn build_with_data( 152 self, 153 extra_data: std::collections::BTreeMap< 154 jacquard_common::smol_str::SmolStr, 155 jacquard_common::types::value::Data<'a>, 156 >, 157 ) -> RemoveOptions<'a> { 158 RemoveOptions { 159 keys: self.__unsafe_private_named.0.unwrap(), 160 scope: self.__unsafe_private_named.1.unwrap(), 161 extra_data: Some(extra_data), 162 } 163 } 164} 165 166#[derive(Debug, Clone, PartialEq, Eq, Hash)] 167pub enum RemoveOptionsScope<'a> { 168 Instance, 169 Personal, 170 Other(jacquard_common::CowStr<'a>), 171} 172 173impl<'a> RemoveOptionsScope<'a> { 174 pub fn as_str(&self) -> &str { 175 match self { 176 Self::Instance => "instance", 177 Self::Personal => "personal", 178 Self::Other(s) => s.as_ref(), 179 } 180 } 181} 182 183impl<'a> From<&'a str> for RemoveOptionsScope<'a> { 184 fn from(s: &'a str) -> Self { 185 match s { 186 "instance" => Self::Instance, 187 "personal" => Self::Personal, 188 _ => Self::Other(jacquard_common::CowStr::from(s)), 189 } 190 } 191} 192 193impl<'a> From<String> for RemoveOptionsScope<'a> { 194 fn from(s: String) -> Self { 195 match s.as_str() { 196 "instance" => Self::Instance, 197 "personal" => Self::Personal, 198 _ => Self::Other(jacquard_common::CowStr::from(s)), 199 } 200 } 201} 202 203impl<'a> core::fmt::Display for RemoveOptionsScope<'a> { 204 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 205 write!(f, "{}", self.as_str()) 206 } 207} 208 209impl<'a> AsRef<str> for RemoveOptionsScope<'a> { 210 fn as_ref(&self) -> &str { 211 self.as_str() 212 } 213} 214 215impl<'a> serde::Serialize for RemoveOptionsScope<'a> { 216 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 217 where 218 S: serde::Serializer, 219 { 220 serializer.serialize_str(self.as_str()) 221 } 222} 223 224impl<'de, 'a> serde::Deserialize<'de> for RemoveOptionsScope<'a> 225where 226 'de: 'a, 227{ 228 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 229 where 230 D: serde::Deserializer<'de>, 231 { 232 let s = <&'de str>::deserialize(deserializer)?; 233 Ok(Self::from(s)) 234 } 235} 236 237impl<'a> Default for RemoveOptionsScope<'a> { 238 fn default() -> Self { 239 Self::Other(Default::default()) 240 } 241} 242 243impl jacquard_common::IntoStatic for RemoveOptionsScope<'_> { 244 type Output = RemoveOptionsScope<'static>; 245 fn into_static(self) -> Self::Output { 246 match self { 247 RemoveOptionsScope::Instance => RemoveOptionsScope::Instance, 248 RemoveOptionsScope::Personal => RemoveOptionsScope::Personal, 249 RemoveOptionsScope::Other(v) => RemoveOptionsScope::Other(v.into_static()), 250 } 251 } 252} 253 254#[jacquard_derive::lexicon] 255#[derive( 256 serde::Serialize, 257 serde::Deserialize, 258 Debug, 259 Clone, 260 PartialEq, 261 Eq, 262 jacquard_derive::IntoStatic, 263 Default 264)] 265#[serde(rename_all = "camelCase")] 266pub struct RemoveOptionsOutput<'a> {} 267/// Response type for 268///tools.ozone.setting.removeOptions 269pub struct RemoveOptionsResponse; 270impl jacquard_common::xrpc::XrpcResp for RemoveOptionsResponse { 271 const NSID: &'static str = "tools.ozone.setting.removeOptions"; 272 const ENCODING: &'static str = "application/json"; 273 type Output<'de> = RemoveOptionsOutput<'de>; 274 type Err<'de> = jacquard_common::xrpc::GenericError<'de>; 275} 276 277impl<'a> jacquard_common::xrpc::XrpcRequest for RemoveOptions<'a> { 278 const NSID: &'static str = "tools.ozone.setting.removeOptions"; 279 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 280 "application/json", 281 ); 282 type Response = RemoveOptionsResponse; 283} 284 285/// Endpoint type for 286///tools.ozone.setting.removeOptions 287pub struct RemoveOptionsRequest; 288impl jacquard_common::xrpc::XrpcEndpoint for RemoveOptionsRequest { 289 const PATH: &'static str = "/xrpc/tools.ozone.setting.removeOptions"; 290 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 291 "application/json", 292 ); 293 type Request<'de> = RemoveOptions<'de>; 294 type Response = RemoveOptionsResponse; 295}