A better Rust ATProto crate
102
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 275 lines 9.8 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: test.ns2.consumer 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// An object that references types across namespaces. 9 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic 18)] 19 20#[serde( 21 rename_all = "camelCase", 22 bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 23)] 24pub struct Consumer<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 25 #[serde(skip_serializing_if = "core::option::Option::is_none")] 26 pub description: core::option::Option<S>, 27 pub item: crate::macro_mode::test_ns1::Foo<S>, 28 #[serde(skip_serializing_if = "core::option::Option::is_none")] 29 pub tags: core::option::Option<Vec<crate::macro_mode::test_ns1::Bar<S>>>, 30 #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 31 pub extra_data: core::option::Option< 32 alloc::collections::BTreeMap< 33 jacquard_common::deps::smol_str::SmolStr, 34 jacquard_common::types::value::Data<S>, 35 >, 36 >, 37} 38 39impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 40for Consumer<S> { 41 fn nsid() -> &'static str { 42 "test.ns2.consumer" 43 } 44 fn def_name() -> &'static str { 45 "main" 46 } 47 fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 48 lexicon_doc_test_ns2_consumer() 49 } 50 fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 51 if let Some(ref value) = self.description { 52 #[allow(unused_comparisons)] 53 if <str>::len(value.as_ref()) > 500usize { 54 return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 55 path: jacquard_lexicon::validation::ValidationPath::from_field( 56 "description", 57 ), 58 max: 500usize, 59 actual: <str>::len(value.as_ref()), 60 }); 61 } 62 } 63 Ok(()) 64 } 65} 66 67pub mod consumer_state { 68 69 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 70 #[allow(unused)] 71 use ::core::marker::PhantomData; 72 mod sealed { 73 pub trait Sealed {} 74 } 75 /// State trait tracking which required fields have been set 76 pub trait State: sealed::Sealed { 77 type Item; 78 } 79 /// Empty state - all required fields are unset 80 pub struct Empty(()); 81 impl sealed::Sealed for Empty {} 82 impl State for Empty { 83 type Item = Unset; 84 } 85 ///State transition - sets the `item` field to Set 86 pub struct SetItem<St: State = Empty>(PhantomData<fn() -> St>); 87 impl<St: State> sealed::Sealed for SetItem<St> {} 88 impl<St: State> State for SetItem<St> { 89 type Item = Set<members::item>; 90 } 91 /// Marker types for field names 92 #[allow(non_camel_case_types)] 93 pub mod members { 94 ///Marker type for the `item` field 95 pub struct item(()); 96 } 97} 98 99/// Builder for constructing an instance of this type. 100pub struct ConsumerBuilder<S: jacquard_common::BosStr, St: consumer_state::State> { 101 _state: ::core::marker::PhantomData<fn() -> St>, 102 _fields: ( 103 core::option::Option<S>, 104 core::option::Option<crate::macro_mode::test_ns1::Foo<S>>, 105 core::option::Option<Vec<crate::macro_mode::test_ns1::Bar<S>>>, 106 ), 107 _type: ::core::marker::PhantomData<fn() -> S>, 108} 109 110impl<S: jacquard_common::BosStr> Consumer<S> { 111 /// Create a new builder for this type. 112 pub fn new() -> ConsumerBuilder<S, consumer_state::Empty> { 113 ConsumerBuilder::new() 114 } 115} 116 117impl<S: jacquard_common::BosStr> ConsumerBuilder<S, consumer_state::Empty> { 118 /// Create a new builder with all fields unset. 119 pub fn new() -> Self { 120 ConsumerBuilder { 121 _state: ::core::marker::PhantomData, 122 _fields: (None, None, None), 123 _type: ::core::marker::PhantomData, 124 } 125 } 126} 127 128impl<S: jacquard_common::BosStr, St: consumer_state::State> ConsumerBuilder<S, St> { 129 /// Set the `description` field (optional) 130 pub fn description(mut self, value: impl Into<Option<S>>) -> Self { 131 self._fields.0 = value.into(); 132 self 133 } 134 /// Set the `description` field to an Option value (optional) 135 pub fn maybe_description(mut self, value: Option<S>) -> Self { 136 self._fields.0 = value; 137 self 138 } 139} 140 141impl<S: jacquard_common::BosStr, St> ConsumerBuilder<S, St> 142where 143 St: consumer_state::State, 144 St::Item: consumer_state::IsUnset, 145{ 146 /// Set the `item` field (required) 147 pub fn item( 148 mut self, 149 value: impl Into<crate::macro_mode::test_ns1::Foo<S>>, 150 ) -> ConsumerBuilder<S, consumer_state::SetItem<St>> { 151 self._fields.1 = ::core::option::Option::Some(value.into()); 152 ConsumerBuilder { 153 _state: ::core::marker::PhantomData, 154 _fields: self._fields, 155 _type: ::core::marker::PhantomData, 156 } 157 } 158} 159 160impl<S: jacquard_common::BosStr, St: consumer_state::State> ConsumerBuilder<S, St> { 161 /// Set the `tags` field (optional) 162 pub fn tags( 163 mut self, 164 value: impl Into<Option<Vec<crate::macro_mode::test_ns1::Bar<S>>>>, 165 ) -> Self { 166 self._fields.2 = value.into(); 167 self 168 } 169 /// Set the `tags` field to an Option value (optional) 170 pub fn maybe_tags( 171 mut self, 172 value: Option<Vec<crate::macro_mode::test_ns1::Bar<S>>>, 173 ) -> Self { 174 self._fields.2 = value; 175 self 176 } 177} 178 179impl<S: jacquard_common::BosStr, St> ConsumerBuilder<S, St> 180where 181 St: consumer_state::State, 182 St::Item: consumer_state::IsSet, 183{ 184 /// Build the final struct. 185 pub fn build(self) -> Consumer<S> { 186 Consumer { 187 description: self._fields.0, 188 item: self._fields.1.unwrap(), 189 tags: self._fields.2, 190 extra_data: Default::default(), 191 } 192 } 193 /// Build the final struct with custom extra_data. 194 pub fn build_with_data( 195 self, 196 extra_data: alloc::collections::BTreeMap< 197 jacquard_common::deps::smol_str::SmolStr, 198 jacquard_common::types::value::Data<S>, 199 >, 200 ) -> Consumer<S> { 201 Consumer { 202 description: self._fields.0, 203 item: self._fields.1.unwrap(), 204 tags: self._fields.2, 205 extra_data: Some(extra_data), 206 } 207 } 208} 209 210fn lexicon_doc_test_ns2_consumer() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 211 ::jacquard_lexicon::lexicon::LexiconDoc { 212 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 213 id: ::jacquard_common::CowStr::new_static("test.ns2.consumer"), 214 defs: { 215 let mut map = ::alloc::collections::BTreeMap::new(); 216 map.insert( 217 ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 218 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 219 description: Some( 220 ::jacquard_common::CowStr::new_static( 221 "An object that references types across namespaces.", 222 ), 223 ), 224 required: Some( 225 vec![ 226 ::jacquard_common::deps::smol_str::SmolStr::new_static("item") 227 ], 228 ), 229 properties: { 230 #[allow(unused_mut)] 231 let mut map = ::alloc::collections::BTreeMap::new(); 232 map.insert( 233 ::jacquard_common::deps::smol_str::SmolStr::new_static( 234 "description", 235 ), 236 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 237 max_length: Some(500usize), 238 ..Default::default() 239 }), 240 ); 241 map.insert( 242 ::jacquard_common::deps::smol_str::SmolStr::new_static( 243 "item", 244 ), 245 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 246 r#ref: ::jacquard_common::CowStr::new_static( 247 "test.ns1.defs#foo", 248 ), 249 ..Default::default() 250 }), 251 ); 252 map.insert( 253 ::jacquard_common::deps::smol_str::SmolStr::new_static( 254 "tags", 255 ), 256 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 257 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 258 r#ref: ::jacquard_common::CowStr::new_static( 259 "test.ns1.defs#bar", 260 ), 261 ..Default::default() 262 }), 263 ..Default::default() 264 }), 265 ); 266 map 267 }, 268 ..Default::default() 269 }), 270 ); 271 map 272 }, 273 ..Default::default() 274 } 275}