A better Rust ATProto crate
103
fork

Configure Feed

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

various fixes, version bump - refactored some stuff in the reworked oauth scopes module - moved tests from jacquard-lexicon into jacquard-codegen-tests crate to remove a circular dev dep that was being annoying during version bump publishing

+13940 -129
+25 -10
Cargo.lock
··· 2159 2159 2160 2160 [[package]] 2161 2161 name = "jacquard" 2162 - version = "0.12.0-beta.1" 2162 + version = "0.12.0-beta.2" 2163 2163 dependencies = [ 2164 2164 "bytes", 2165 2165 "clap", ··· 2193 2193 2194 2194 [[package]] 2195 2195 name = "jacquard-api" 2196 - version = "0.12.0-beta.1" 2196 + version = "0.12.0-beta.2" 2197 2197 dependencies = [ 2198 2198 "jacquard-common", 2199 2199 "jacquard-derive", ··· 2204 2204 ] 2205 2205 2206 2206 [[package]] 2207 + name = "jacquard-codegen-tests" 2208 + version = "0.0.0" 2209 + dependencies = [ 2210 + "inventory", 2211 + "jacquard-common", 2212 + "jacquard-derive", 2213 + "jacquard-lexicon", 2214 + "miette", 2215 + "serde", 2216 + "serde_ipld_dagcbor", 2217 + "serde_json", 2218 + "smol_str", 2219 + "thiserror 2.0.18", 2220 + ] 2221 + 2222 + [[package]] 2207 2223 name = "jacquard-common" 2208 - version = "0.12.0-beta.1" 2224 + version = "0.12.0-beta.2" 2209 2225 dependencies = [ 2210 2226 "base64 0.22.1", 2211 2227 "bon", ··· 2260 2276 2261 2277 [[package]] 2262 2278 name = "jacquard-derive" 2263 - version = "0.12.0-beta.1" 2279 + version = "0.12.0-beta.2" 2264 2280 dependencies = [ 2265 2281 "heck 0.5.0", 2266 2282 "inventory", ··· 2276 2292 2277 2293 [[package]] 2278 2294 name = "jacquard-identity" 2279 - version = "0.12.0-beta.1" 2295 + version = "0.12.0-beta.2" 2280 2296 dependencies = [ 2281 2297 "bon", 2282 2298 "bytes", ··· 2299 2315 2300 2316 [[package]] 2301 2317 name = "jacquard-lexgen" 2302 - version = "0.12.0-beta.1" 2318 + version = "0.12.0-beta.2" 2303 2319 dependencies = [ 2304 2320 "clap", 2305 2321 "clap_complete", ··· 2325 2341 2326 2342 [[package]] 2327 2343 name = "jacquard-lexicon" 2328 - version = "0.12.0-beta.1" 2344 + version = "0.12.0-beta.2" 2329 2345 dependencies = [ 2330 2346 "bytes", 2331 2347 "cid", ··· 2333 2349 "heck 0.5.0", 2334 2350 "inventory", 2335 2351 "jacquard-common", 2336 - "jacquard-derive", 2337 2352 "miette", 2338 2353 "multihash", 2339 2354 "prettyplease", ··· 2354 2369 2355 2370 [[package]] 2356 2371 name = "jacquard-oauth" 2357 - version = "0.12.0-beta.1" 2372 + version = "0.12.0-beta.2" 2358 2373 dependencies = [ 2359 2374 "base64 0.22.1", 2360 2375 "bytes", ··· 2390 2405 2391 2406 [[package]] 2392 2407 name = "jacquard-repo" 2393 - version = "0.12.0-beta.1" 2408 + version = "0.12.0-beta.2" 2394 2409 dependencies = [ 2395 2410 "anyhow", 2396 2411 "bytes",
+2 -2
Cargo.toml
··· 1 1 [workspace] 2 2 resolver = "2" 3 - members = ["crates/jacquard", "crates/jacquard-common", "crates/jacquard-api", "crates/jacquard-lexgen", "crates/jacquard-lexicon", "crates/jacquard-derive", "crates/jacquard-repo", "crates/mini-moka-wasm"] 3 + members = ["crates/jacquard", "crates/jacquard-common", "crates/jacquard-api", "crates/jacquard-lexgen", "crates/jacquard-lexicon", "crates/jacquard-derive", "crates/jacquard-repo", "crates/jacquard-codegen-tests", "crates/mini-moka-wasm"] 4 4 5 5 6 6 [workspace.package] 7 7 edition = "2024" 8 - version = "0.12.0-beta.1" 8 + version = "0.12.0-beta.2" 9 9 authors = ["Orual <orual@nonbinary.computer>"] 10 10 #repository = "https://github.com/rsform/jacquard" 11 11 repository = "https://tangled.org/nonbinary.computer/jacquard"
+1 -1
crates/jacquard-api/Cargo.toml
··· 2 2 name = "jacquard-api" 3 3 description = "Generated AT Protocol API bindings for Jacquard" 4 4 edition.workspace = true 5 - version = "0.12.0-beta.1" 5 + version = "0.12.0-beta.2" 6 6 authors.workspace = true 7 7 repository.workspace = true 8 8 keywords.workspace = true
+1 -1
crates/jacquard-axum/Cargo.toml
··· 1 1 [package] 2 2 name = "jacquard-axum" 3 3 edition.workspace = true 4 - version = "0.12.0-beta.1" 4 + version = "0.12.0-beta.2" 5 5 authors.workspace = true 6 6 repository.workspace = true 7 7 keywords.workspace = true
+1
crates/jacquard-codegen-tests/.gitignore
··· 1 + src/generated
+1
crates/jacquard-codegen-tests/Cargo.toml
··· 10 10 jacquard-common = { path = "../jacquard-common" } 11 11 jacquard-derive = { path = "../jacquard-derive" } 12 12 jacquard-lexicon = { path = "../jacquard-lexicon" } 13 + inventory = "0.3" 13 14 serde = { workspace = true } 14 15 smol_str = { workspace = true } 15 16 thiserror = { workspace = true }
+7
crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod embed; 7 + pub mod richtext;
+6
crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/embed.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod external;
+1022
crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/embed/external.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: app.bsky.embed.external 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 + jacquard_derive::IntoStatic 16 + )] 17 + 18 + #[serde( 19 + rename_all = "camelCase", 20 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 21 + )] 22 + pub struct External<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 23 + pub description: S, 24 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 25 + pub thumb: core::option::Option<jacquard_common::types::blob::BlobRef<S>>, 26 + pub title: S, 27 + pub uri: jacquard_common::types::string::UriValue<S>, 28 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 29 + pub extra_data: core::option::Option< 30 + alloc::collections::BTreeMap< 31 + jacquard_common::deps::smol_str::SmolStr, 32 + jacquard_common::types::value::Data<S>, 33 + >, 34 + >, 35 + } 36 + 37 + /// A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post). 38 + 39 + #[derive( 40 + serde::Serialize, 41 + serde::Deserialize, 42 + Debug, 43 + Clone, 44 + PartialEq, 45 + Eq, 46 + jacquard_derive::IntoStatic 47 + )] 48 + 49 + #[serde( 50 + rename_all = "camelCase", 51 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 52 + )] 53 + pub struct ExternalRecord<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 54 + pub external: crate::macro_mode::app_bsky::embed::external::External<S>, 55 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 56 + pub extra_data: core::option::Option< 57 + alloc::collections::BTreeMap< 58 + jacquard_common::deps::smol_str::SmolStr, 59 + jacquard_common::types::value::Data<S>, 60 + >, 61 + >, 62 + } 63 + 64 + 65 + #[derive( 66 + serde::Serialize, 67 + serde::Deserialize, 68 + Debug, 69 + Clone, 70 + PartialEq, 71 + Eq, 72 + jacquard_derive::IntoStatic 73 + )] 74 + 75 + #[serde( 76 + rename_all = "camelCase", 77 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 78 + )] 79 + pub struct View<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 80 + pub external: crate::macro_mode::app_bsky::embed::external::ViewExternal<S>, 81 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 82 + pub extra_data: core::option::Option< 83 + alloc::collections::BTreeMap< 84 + jacquard_common::deps::smol_str::SmolStr, 85 + jacquard_common::types::value::Data<S>, 86 + >, 87 + >, 88 + } 89 + 90 + 91 + #[derive( 92 + serde::Serialize, 93 + serde::Deserialize, 94 + Debug, 95 + Clone, 96 + PartialEq, 97 + Eq, 98 + jacquard_derive::IntoStatic 99 + )] 100 + 101 + #[serde( 102 + rename_all = "camelCase", 103 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 104 + )] 105 + pub struct ViewExternal<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 106 + pub description: S, 107 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 108 + pub thumb: core::option::Option<jacquard_common::types::string::UriValue<S>>, 109 + pub title: S, 110 + pub uri: jacquard_common::types::string::UriValue<S>, 111 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 112 + pub extra_data: core::option::Option< 113 + alloc::collections::BTreeMap< 114 + jacquard_common::deps::smol_str::SmolStr, 115 + jacquard_common::types::value::Data<S>, 116 + >, 117 + >, 118 + } 119 + 120 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 121 + for External<S> { 122 + fn nsid() -> &'static str { 123 + "app.bsky.embed.external" 124 + } 125 + fn def_name() -> &'static str { 126 + "external" 127 + } 128 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 129 + lexicon_doc_app_bsky_embed_external() 130 + } 131 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 132 + if let Some(ref value) = self.thumb { 133 + { 134 + let size = value.blob().size; 135 + if size > 1000000usize { 136 + return Err(jacquard_lexicon::validation::ConstraintError::BlobTooLarge { 137 + path: jacquard_lexicon::validation::ValidationPath::from_field( 138 + "thumb", 139 + ), 140 + max: 1000000usize, 141 + actual: size, 142 + }); 143 + } 144 + } 145 + } 146 + if let Some(ref value) = self.thumb { 147 + { 148 + let mime = value.blob().mime_type.as_str(); 149 + let accepted: &[&str] = &["image/*"]; 150 + let matched = accepted 151 + .iter() 152 + .any(|pattern| { 153 + if *pattern == "*/*" { 154 + true 155 + } else if pattern.ends_with("/*") { 156 + let prefix = &pattern[..pattern.len() - 2]; 157 + mime.starts_with(prefix) 158 + && mime.as_bytes().get(prefix.len()) == Some(&b'/') 159 + } else { 160 + mime == *pattern 161 + } 162 + }); 163 + if !matched { 164 + return Err(jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted { 165 + path: jacquard_lexicon::validation::ValidationPath::from_field( 166 + "thumb", 167 + ), 168 + accepted: vec!["image/*".to_string()], 169 + actual: mime.to_string(), 170 + }); 171 + } 172 + } 173 + } 174 + Ok(()) 175 + } 176 + } 177 + 178 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 179 + for ExternalRecord<S> { 180 + fn nsid() -> &'static str { 181 + "app.bsky.embed.external" 182 + } 183 + fn def_name() -> &'static str { 184 + "main" 185 + } 186 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 187 + lexicon_doc_app_bsky_embed_external() 188 + } 189 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 190 + Ok(()) 191 + } 192 + } 193 + 194 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for View<S> { 195 + fn nsid() -> &'static str { 196 + "app.bsky.embed.external" 197 + } 198 + fn def_name() -> &'static str { 199 + "view" 200 + } 201 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 202 + lexicon_doc_app_bsky_embed_external() 203 + } 204 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 205 + Ok(()) 206 + } 207 + } 208 + 209 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 210 + for ViewExternal<S> { 211 + fn nsid() -> &'static str { 212 + "app.bsky.embed.external" 213 + } 214 + fn def_name() -> &'static str { 215 + "viewExternal" 216 + } 217 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 218 + lexicon_doc_app_bsky_embed_external() 219 + } 220 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 221 + Ok(()) 222 + } 223 + } 224 + 225 + pub mod external_state { 226 + 227 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 228 + #[allow(unused)] 229 + use ::core::marker::PhantomData; 230 + mod sealed { 231 + pub trait Sealed {} 232 + } 233 + /// State trait tracking which required fields have been set 234 + pub trait State: sealed::Sealed { 235 + type Uri; 236 + type Title; 237 + type Description; 238 + } 239 + /// Empty state - all required fields are unset 240 + pub struct Empty(()); 241 + impl sealed::Sealed for Empty {} 242 + impl State for Empty { 243 + type Uri = Unset; 244 + type Title = Unset; 245 + type Description = Unset; 246 + } 247 + ///State transition - sets the `uri` field to Set 248 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 249 + impl<St: State> sealed::Sealed for SetUri<St> {} 250 + impl<St: State> State for SetUri<St> { 251 + type Uri = Set<members::uri>; 252 + type Title = St::Title; 253 + type Description = St::Description; 254 + } 255 + ///State transition - sets the `title` field to Set 256 + pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>); 257 + impl<St: State> sealed::Sealed for SetTitle<St> {} 258 + impl<St: State> State for SetTitle<St> { 259 + type Uri = St::Uri; 260 + type Title = Set<members::title>; 261 + type Description = St::Description; 262 + } 263 + ///State transition - sets the `description` field to Set 264 + pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>); 265 + impl<St: State> sealed::Sealed for SetDescription<St> {} 266 + impl<St: State> State for SetDescription<St> { 267 + type Uri = St::Uri; 268 + type Title = St::Title; 269 + type Description = Set<members::description>; 270 + } 271 + /// Marker types for field names 272 + #[allow(non_camel_case_types)] 273 + pub mod members { 274 + ///Marker type for the `uri` field 275 + pub struct uri(()); 276 + ///Marker type for the `title` field 277 + pub struct title(()); 278 + ///Marker type for the `description` field 279 + pub struct description(()); 280 + } 281 + } 282 + 283 + /// Builder for constructing an instance of this type. 284 + pub struct ExternalBuilder<S: jacquard_common::BosStr, St: external_state::State> { 285 + _state: ::core::marker::PhantomData<fn() -> St>, 286 + _fields: ( 287 + core::option::Option<S>, 288 + core::option::Option<jacquard_common::types::blob::BlobRef<S>>, 289 + core::option::Option<S>, 290 + core::option::Option<jacquard_common::types::string::UriValue<S>>, 291 + ), 292 + _type: ::core::marker::PhantomData<fn() -> S>, 293 + } 294 + 295 + impl<S: jacquard_common::BosStr> External<S> { 296 + /// Create a new builder for this type. 297 + pub fn new() -> ExternalBuilder<S, external_state::Empty> { 298 + ExternalBuilder::new() 299 + } 300 + } 301 + 302 + impl<S: jacquard_common::BosStr> ExternalBuilder<S, external_state::Empty> { 303 + /// Create a new builder with all fields unset. 304 + pub fn new() -> Self { 305 + ExternalBuilder { 306 + _state: ::core::marker::PhantomData, 307 + _fields: (None, None, None, None), 308 + _type: ::core::marker::PhantomData, 309 + } 310 + } 311 + } 312 + 313 + impl<S: jacquard_common::BosStr, St> ExternalBuilder<S, St> 314 + where 315 + St: external_state::State, 316 + St::Description: external_state::IsUnset, 317 + { 318 + /// Set the `description` field (required) 319 + pub fn description( 320 + mut self, 321 + value: impl Into<S>, 322 + ) -> ExternalBuilder<S, external_state::SetDescription<St>> { 323 + self._fields.0 = ::core::option::Option::Some(value.into()); 324 + ExternalBuilder { 325 + _state: ::core::marker::PhantomData, 326 + _fields: self._fields, 327 + _type: ::core::marker::PhantomData, 328 + } 329 + } 330 + } 331 + 332 + impl<S: jacquard_common::BosStr, St: external_state::State> ExternalBuilder<S, St> { 333 + /// Set the `thumb` field (optional) 334 + pub fn thumb( 335 + mut self, 336 + value: impl Into<Option<jacquard_common::types::blob::BlobRef<S>>>, 337 + ) -> Self { 338 + self._fields.1 = value.into(); 339 + self 340 + } 341 + /// Set the `thumb` field to an Option value (optional) 342 + pub fn maybe_thumb( 343 + mut self, 344 + value: Option<jacquard_common::types::blob::BlobRef<S>>, 345 + ) -> Self { 346 + self._fields.1 = value; 347 + self 348 + } 349 + } 350 + 351 + impl<S: jacquard_common::BosStr, St> ExternalBuilder<S, St> 352 + where 353 + St: external_state::State, 354 + St::Title: external_state::IsUnset, 355 + { 356 + /// Set the `title` field (required) 357 + pub fn title( 358 + mut self, 359 + value: impl Into<S>, 360 + ) -> ExternalBuilder<S, external_state::SetTitle<St>> { 361 + self._fields.2 = ::core::option::Option::Some(value.into()); 362 + ExternalBuilder { 363 + _state: ::core::marker::PhantomData, 364 + _fields: self._fields, 365 + _type: ::core::marker::PhantomData, 366 + } 367 + } 368 + } 369 + 370 + impl<S: jacquard_common::BosStr, St> ExternalBuilder<S, St> 371 + where 372 + St: external_state::State, 373 + St::Uri: external_state::IsUnset, 374 + { 375 + /// Set the `uri` field (required) 376 + pub fn uri( 377 + mut self, 378 + value: impl Into<jacquard_common::types::string::UriValue<S>>, 379 + ) -> ExternalBuilder<S, external_state::SetUri<St>> { 380 + self._fields.3 = ::core::option::Option::Some(value.into()); 381 + ExternalBuilder { 382 + _state: ::core::marker::PhantomData, 383 + _fields: self._fields, 384 + _type: ::core::marker::PhantomData, 385 + } 386 + } 387 + } 388 + 389 + impl<S: jacquard_common::BosStr, St> ExternalBuilder<S, St> 390 + where 391 + St: external_state::State, 392 + St::Uri: external_state::IsSet, 393 + St::Title: external_state::IsSet, 394 + St::Description: external_state::IsSet, 395 + { 396 + /// Build the final struct. 397 + pub fn build(self) -> External<S> { 398 + External { 399 + description: self._fields.0.unwrap(), 400 + thumb: self._fields.1, 401 + title: self._fields.2.unwrap(), 402 + uri: self._fields.3.unwrap(), 403 + extra_data: Default::default(), 404 + } 405 + } 406 + /// Build the final struct with custom extra_data. 407 + pub fn build_with_data( 408 + self, 409 + extra_data: alloc::collections::BTreeMap< 410 + jacquard_common::deps::smol_str::SmolStr, 411 + jacquard_common::types::value::Data<S>, 412 + >, 413 + ) -> External<S> { 414 + External { 415 + description: self._fields.0.unwrap(), 416 + thumb: self._fields.1, 417 + title: self._fields.2.unwrap(), 418 + uri: self._fields.3.unwrap(), 419 + extra_data: Some(extra_data), 420 + } 421 + } 422 + } 423 + 424 + fn lexicon_doc_app_bsky_embed_external() -> jacquard_lexicon::lexicon::LexiconDoc< 425 + 'static, 426 + > { 427 + ::jacquard_lexicon::lexicon::LexiconDoc { 428 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 429 + id: ::jacquard_common::CowStr::new_static("app.bsky.embed.external"), 430 + defs: { 431 + let mut map = ::alloc::collections::BTreeMap::new(); 432 + map.insert( 433 + ::jacquard_common::deps::smol_str::SmolStr::new_static("external"), 434 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 435 + required: Some( 436 + vec![ 437 + ::jacquard_common::deps::smol_str::SmolStr::new_static("uri"), 438 + ::jacquard_common::deps::smol_str::SmolStr::new_static("title"), 439 + ::jacquard_common::deps::smol_str::SmolStr::new_static("description") 440 + ], 441 + ), 442 + properties: { 443 + #[allow(unused_mut)] 444 + let mut map = ::alloc::collections::BTreeMap::new(); 445 + map.insert( 446 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 447 + "description", 448 + ), 449 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 450 + ..Default::default() 451 + }), 452 + ); 453 + map.insert( 454 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 455 + "thumb", 456 + ), 457 + ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { 458 + ..Default::default() 459 + }), 460 + ); 461 + map.insert( 462 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 463 + "title", 464 + ), 465 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 466 + ..Default::default() 467 + }), 468 + ); 469 + map.insert( 470 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 471 + "uri", 472 + ), 473 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 474 + format: Some( 475 + ::jacquard_lexicon::lexicon::LexStringFormat::Uri, 476 + ), 477 + ..Default::default() 478 + }), 479 + ); 480 + map 481 + }, 482 + ..Default::default() 483 + }), 484 + ); 485 + map.insert( 486 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 487 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 488 + description: Some( 489 + ::jacquard_common::CowStr::new_static( 490 + "A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post).", 491 + ), 492 + ), 493 + required: Some( 494 + vec![ 495 + ::jacquard_common::deps::smol_str::SmolStr::new_static("external") 496 + ], 497 + ), 498 + properties: { 499 + #[allow(unused_mut)] 500 + let mut map = ::alloc::collections::BTreeMap::new(); 501 + map.insert( 502 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 503 + "external", 504 + ), 505 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 506 + r#ref: ::jacquard_common::CowStr::new_static("#external"), 507 + ..Default::default() 508 + }), 509 + ); 510 + map 511 + }, 512 + ..Default::default() 513 + }), 514 + ); 515 + map.insert( 516 + ::jacquard_common::deps::smol_str::SmolStr::new_static("view"), 517 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 518 + required: Some( 519 + vec![ 520 + ::jacquard_common::deps::smol_str::SmolStr::new_static("external") 521 + ], 522 + ), 523 + properties: { 524 + #[allow(unused_mut)] 525 + let mut map = ::alloc::collections::BTreeMap::new(); 526 + map.insert( 527 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 528 + "external", 529 + ), 530 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 531 + r#ref: ::jacquard_common::CowStr::new_static( 532 + "#viewExternal", 533 + ), 534 + ..Default::default() 535 + }), 536 + ); 537 + map 538 + }, 539 + ..Default::default() 540 + }), 541 + ); 542 + map.insert( 543 + ::jacquard_common::deps::smol_str::SmolStr::new_static("viewExternal"), 544 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 545 + required: Some( 546 + vec![ 547 + ::jacquard_common::deps::smol_str::SmolStr::new_static("uri"), 548 + ::jacquard_common::deps::smol_str::SmolStr::new_static("title"), 549 + ::jacquard_common::deps::smol_str::SmolStr::new_static("description") 550 + ], 551 + ), 552 + properties: { 553 + #[allow(unused_mut)] 554 + let mut map = ::alloc::collections::BTreeMap::new(); 555 + map.insert( 556 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 557 + "description", 558 + ), 559 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 560 + ..Default::default() 561 + }), 562 + ); 563 + map.insert( 564 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 565 + "thumb", 566 + ), 567 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 568 + format: Some( 569 + ::jacquard_lexicon::lexicon::LexStringFormat::Uri, 570 + ), 571 + ..Default::default() 572 + }), 573 + ); 574 + map.insert( 575 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 576 + "title", 577 + ), 578 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 579 + ..Default::default() 580 + }), 581 + ); 582 + map.insert( 583 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 584 + "uri", 585 + ), 586 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 587 + format: Some( 588 + ::jacquard_lexicon::lexicon::LexStringFormat::Uri, 589 + ), 590 + ..Default::default() 591 + }), 592 + ); 593 + map 594 + }, 595 + ..Default::default() 596 + }), 597 + ); 598 + map 599 + }, 600 + ..Default::default() 601 + } 602 + } 603 + 604 + pub mod external_record_state { 605 + 606 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 607 + #[allow(unused)] 608 + use ::core::marker::PhantomData; 609 + mod sealed { 610 + pub trait Sealed {} 611 + } 612 + /// State trait tracking which required fields have been set 613 + pub trait State: sealed::Sealed { 614 + type External; 615 + } 616 + /// Empty state - all required fields are unset 617 + pub struct Empty(()); 618 + impl sealed::Sealed for Empty {} 619 + impl State for Empty { 620 + type External = Unset; 621 + } 622 + ///State transition - sets the `external` field to Set 623 + pub struct SetExternal<St: State = Empty>(PhantomData<fn() -> St>); 624 + impl<St: State> sealed::Sealed for SetExternal<St> {} 625 + impl<St: State> State for SetExternal<St> { 626 + type External = Set<members::external>; 627 + } 628 + /// Marker types for field names 629 + #[allow(non_camel_case_types)] 630 + pub mod members { 631 + ///Marker type for the `external` field 632 + pub struct external(()); 633 + } 634 + } 635 + 636 + /// Builder for constructing an instance of this type. 637 + pub struct ExternalRecordBuilder< 638 + S: jacquard_common::BosStr, 639 + St: external_record_state::State, 640 + > { 641 + _state: ::core::marker::PhantomData<fn() -> St>, 642 + _fields: ( 643 + core::option::Option<crate::macro_mode::app_bsky::embed::external::External<S>>, 644 + ), 645 + _type: ::core::marker::PhantomData<fn() -> S>, 646 + } 647 + 648 + impl<S: jacquard_common::BosStr> ExternalRecord<S> { 649 + /// Create a new builder for this type. 650 + pub fn new() -> ExternalRecordBuilder<S, external_record_state::Empty> { 651 + ExternalRecordBuilder::new() 652 + } 653 + } 654 + 655 + impl<S: jacquard_common::BosStr> ExternalRecordBuilder<S, external_record_state::Empty> { 656 + /// Create a new builder with all fields unset. 657 + pub fn new() -> Self { 658 + ExternalRecordBuilder { 659 + _state: ::core::marker::PhantomData, 660 + _fields: (None,), 661 + _type: ::core::marker::PhantomData, 662 + } 663 + } 664 + } 665 + 666 + impl<S: jacquard_common::BosStr, St> ExternalRecordBuilder<S, St> 667 + where 668 + St: external_record_state::State, 669 + St::External: external_record_state::IsUnset, 670 + { 671 + /// Set the `external` field (required) 672 + pub fn external( 673 + mut self, 674 + value: impl Into<crate::macro_mode::app_bsky::embed::external::External<S>>, 675 + ) -> ExternalRecordBuilder<S, external_record_state::SetExternal<St>> { 676 + self._fields.0 = ::core::option::Option::Some(value.into()); 677 + ExternalRecordBuilder { 678 + _state: ::core::marker::PhantomData, 679 + _fields: self._fields, 680 + _type: ::core::marker::PhantomData, 681 + } 682 + } 683 + } 684 + 685 + impl<S: jacquard_common::BosStr, St> ExternalRecordBuilder<S, St> 686 + where 687 + St: external_record_state::State, 688 + St::External: external_record_state::IsSet, 689 + { 690 + /// Build the final struct. 691 + pub fn build(self) -> ExternalRecord<S> { 692 + ExternalRecord { 693 + external: self._fields.0.unwrap(), 694 + extra_data: Default::default(), 695 + } 696 + } 697 + /// Build the final struct with custom extra_data. 698 + pub fn build_with_data( 699 + self, 700 + extra_data: alloc::collections::BTreeMap< 701 + jacquard_common::deps::smol_str::SmolStr, 702 + jacquard_common::types::value::Data<S>, 703 + >, 704 + ) -> ExternalRecord<S> { 705 + ExternalRecord { 706 + external: self._fields.0.unwrap(), 707 + extra_data: Some(extra_data), 708 + } 709 + } 710 + } 711 + 712 + pub mod view_state { 713 + 714 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 715 + #[allow(unused)] 716 + use ::core::marker::PhantomData; 717 + mod sealed { 718 + pub trait Sealed {} 719 + } 720 + /// State trait tracking which required fields have been set 721 + pub trait State: sealed::Sealed { 722 + type External; 723 + } 724 + /// Empty state - all required fields are unset 725 + pub struct Empty(()); 726 + impl sealed::Sealed for Empty {} 727 + impl State for Empty { 728 + type External = Unset; 729 + } 730 + ///State transition - sets the `external` field to Set 731 + pub struct SetExternal<St: State = Empty>(PhantomData<fn() -> St>); 732 + impl<St: State> sealed::Sealed for SetExternal<St> {} 733 + impl<St: State> State for SetExternal<St> { 734 + type External = Set<members::external>; 735 + } 736 + /// Marker types for field names 737 + #[allow(non_camel_case_types)] 738 + pub mod members { 739 + ///Marker type for the `external` field 740 + pub struct external(()); 741 + } 742 + } 743 + 744 + /// Builder for constructing an instance of this type. 745 + pub struct ViewBuilder<S: jacquard_common::BosStr, St: view_state::State> { 746 + _state: ::core::marker::PhantomData<fn() -> St>, 747 + _fields: ( 748 + core::option::Option< 749 + crate::macro_mode::app_bsky::embed::external::ViewExternal<S>, 750 + >, 751 + ), 752 + _type: ::core::marker::PhantomData<fn() -> S>, 753 + } 754 + 755 + impl<S: jacquard_common::BosStr> View<S> { 756 + /// Create a new builder for this type. 757 + pub fn new() -> ViewBuilder<S, view_state::Empty> { 758 + ViewBuilder::new() 759 + } 760 + } 761 + 762 + impl<S: jacquard_common::BosStr> ViewBuilder<S, view_state::Empty> { 763 + /// Create a new builder with all fields unset. 764 + pub fn new() -> Self { 765 + ViewBuilder { 766 + _state: ::core::marker::PhantomData, 767 + _fields: (None,), 768 + _type: ::core::marker::PhantomData, 769 + } 770 + } 771 + } 772 + 773 + impl<S: jacquard_common::BosStr, St> ViewBuilder<S, St> 774 + where 775 + St: view_state::State, 776 + St::External: view_state::IsUnset, 777 + { 778 + /// Set the `external` field (required) 779 + pub fn external( 780 + mut self, 781 + value: impl Into<crate::macro_mode::app_bsky::embed::external::ViewExternal<S>>, 782 + ) -> ViewBuilder<S, view_state::SetExternal<St>> { 783 + self._fields.0 = ::core::option::Option::Some(value.into()); 784 + ViewBuilder { 785 + _state: ::core::marker::PhantomData, 786 + _fields: self._fields, 787 + _type: ::core::marker::PhantomData, 788 + } 789 + } 790 + } 791 + 792 + impl<S: jacquard_common::BosStr, St> ViewBuilder<S, St> 793 + where 794 + St: view_state::State, 795 + St::External: view_state::IsSet, 796 + { 797 + /// Build the final struct. 798 + pub fn build(self) -> View<S> { 799 + View { 800 + external: self._fields.0.unwrap(), 801 + extra_data: Default::default(), 802 + } 803 + } 804 + /// Build the final struct with custom extra_data. 805 + pub fn build_with_data( 806 + self, 807 + extra_data: alloc::collections::BTreeMap< 808 + jacquard_common::deps::smol_str::SmolStr, 809 + jacquard_common::types::value::Data<S>, 810 + >, 811 + ) -> View<S> { 812 + View { 813 + external: self._fields.0.unwrap(), 814 + extra_data: Some(extra_data), 815 + } 816 + } 817 + } 818 + 819 + pub mod view_external_state { 820 + 821 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 822 + #[allow(unused)] 823 + use ::core::marker::PhantomData; 824 + mod sealed { 825 + pub trait Sealed {} 826 + } 827 + /// State trait tracking which required fields have been set 828 + pub trait State: sealed::Sealed { 829 + type Title; 830 + type Uri; 831 + type Description; 832 + } 833 + /// Empty state - all required fields are unset 834 + pub struct Empty(()); 835 + impl sealed::Sealed for Empty {} 836 + impl State for Empty { 837 + type Title = Unset; 838 + type Uri = Unset; 839 + type Description = Unset; 840 + } 841 + ///State transition - sets the `title` field to Set 842 + pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>); 843 + impl<St: State> sealed::Sealed for SetTitle<St> {} 844 + impl<St: State> State for SetTitle<St> { 845 + type Title = Set<members::title>; 846 + type Uri = St::Uri; 847 + type Description = St::Description; 848 + } 849 + ///State transition - sets the `uri` field to Set 850 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 851 + impl<St: State> sealed::Sealed for SetUri<St> {} 852 + impl<St: State> State for SetUri<St> { 853 + type Title = St::Title; 854 + type Uri = Set<members::uri>; 855 + type Description = St::Description; 856 + } 857 + ///State transition - sets the `description` field to Set 858 + pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>); 859 + impl<St: State> sealed::Sealed for SetDescription<St> {} 860 + impl<St: State> State for SetDescription<St> { 861 + type Title = St::Title; 862 + type Uri = St::Uri; 863 + type Description = Set<members::description>; 864 + } 865 + /// Marker types for field names 866 + #[allow(non_camel_case_types)] 867 + pub mod members { 868 + ///Marker type for the `title` field 869 + pub struct title(()); 870 + ///Marker type for the `uri` field 871 + pub struct uri(()); 872 + ///Marker type for the `description` field 873 + pub struct description(()); 874 + } 875 + } 876 + 877 + /// Builder for constructing an instance of this type. 878 + pub struct ViewExternalBuilder< 879 + S: jacquard_common::BosStr, 880 + St: view_external_state::State, 881 + > { 882 + _state: ::core::marker::PhantomData<fn() -> St>, 883 + _fields: ( 884 + core::option::Option<S>, 885 + core::option::Option<jacquard_common::types::string::UriValue<S>>, 886 + core::option::Option<S>, 887 + core::option::Option<jacquard_common::types::string::UriValue<S>>, 888 + ), 889 + _type: ::core::marker::PhantomData<fn() -> S>, 890 + } 891 + 892 + impl<S: jacquard_common::BosStr> ViewExternal<S> { 893 + /// Create a new builder for this type. 894 + pub fn new() -> ViewExternalBuilder<S, view_external_state::Empty> { 895 + ViewExternalBuilder::new() 896 + } 897 + } 898 + 899 + impl<S: jacquard_common::BosStr> ViewExternalBuilder<S, view_external_state::Empty> { 900 + /// Create a new builder with all fields unset. 901 + pub fn new() -> Self { 902 + ViewExternalBuilder { 903 + _state: ::core::marker::PhantomData, 904 + _fields: (None, None, None, None), 905 + _type: ::core::marker::PhantomData, 906 + } 907 + } 908 + } 909 + 910 + impl<S: jacquard_common::BosStr, St> ViewExternalBuilder<S, St> 911 + where 912 + St: view_external_state::State, 913 + St::Description: view_external_state::IsUnset, 914 + { 915 + /// Set the `description` field (required) 916 + pub fn description( 917 + mut self, 918 + value: impl Into<S>, 919 + ) -> ViewExternalBuilder<S, view_external_state::SetDescription<St>> { 920 + self._fields.0 = ::core::option::Option::Some(value.into()); 921 + ViewExternalBuilder { 922 + _state: ::core::marker::PhantomData, 923 + _fields: self._fields, 924 + _type: ::core::marker::PhantomData, 925 + } 926 + } 927 + } 928 + 929 + impl< 930 + S: jacquard_common::BosStr, 931 + St: view_external_state::State, 932 + > ViewExternalBuilder<S, St> { 933 + /// Set the `thumb` field (optional) 934 + pub fn thumb( 935 + mut self, 936 + value: impl Into<Option<jacquard_common::types::string::UriValue<S>>>, 937 + ) -> Self { 938 + self._fields.1 = value.into(); 939 + self 940 + } 941 + /// Set the `thumb` field to an Option value (optional) 942 + pub fn maybe_thumb( 943 + mut self, 944 + value: Option<jacquard_common::types::string::UriValue<S>>, 945 + ) -> Self { 946 + self._fields.1 = value; 947 + self 948 + } 949 + } 950 + 951 + impl<S: jacquard_common::BosStr, St> ViewExternalBuilder<S, St> 952 + where 953 + St: view_external_state::State, 954 + St::Title: view_external_state::IsUnset, 955 + { 956 + /// Set the `title` field (required) 957 + pub fn title( 958 + mut self, 959 + value: impl Into<S>, 960 + ) -> ViewExternalBuilder<S, view_external_state::SetTitle<St>> { 961 + self._fields.2 = ::core::option::Option::Some(value.into()); 962 + ViewExternalBuilder { 963 + _state: ::core::marker::PhantomData, 964 + _fields: self._fields, 965 + _type: ::core::marker::PhantomData, 966 + } 967 + } 968 + } 969 + 970 + impl<S: jacquard_common::BosStr, St> ViewExternalBuilder<S, St> 971 + where 972 + St: view_external_state::State, 973 + St::Uri: view_external_state::IsUnset, 974 + { 975 + /// Set the `uri` field (required) 976 + pub fn uri( 977 + mut self, 978 + value: impl Into<jacquard_common::types::string::UriValue<S>>, 979 + ) -> ViewExternalBuilder<S, view_external_state::SetUri<St>> { 980 + self._fields.3 = ::core::option::Option::Some(value.into()); 981 + ViewExternalBuilder { 982 + _state: ::core::marker::PhantomData, 983 + _fields: self._fields, 984 + _type: ::core::marker::PhantomData, 985 + } 986 + } 987 + } 988 + 989 + impl<S: jacquard_common::BosStr, St> ViewExternalBuilder<S, St> 990 + where 991 + St: view_external_state::State, 992 + St::Title: view_external_state::IsSet, 993 + St::Uri: view_external_state::IsSet, 994 + St::Description: view_external_state::IsSet, 995 + { 996 + /// Build the final struct. 997 + pub fn build(self) -> ViewExternal<S> { 998 + ViewExternal { 999 + description: self._fields.0.unwrap(), 1000 + thumb: self._fields.1, 1001 + title: self._fields.2.unwrap(), 1002 + uri: self._fields.3.unwrap(), 1003 + extra_data: Default::default(), 1004 + } 1005 + } 1006 + /// Build the final struct with custom extra_data. 1007 + pub fn build_with_data( 1008 + self, 1009 + extra_data: alloc::collections::BTreeMap< 1010 + jacquard_common::deps::smol_str::SmolStr, 1011 + jacquard_common::types::value::Data<S>, 1012 + >, 1013 + ) -> ViewExternal<S> { 1014 + ViewExternal { 1015 + description: self._fields.0.unwrap(), 1016 + thumb: self._fields.1, 1017 + title: self._fields.2.unwrap(), 1018 + uri: self._fields.3.unwrap(), 1019 + extra_data: Some(extra_data), 1020 + } 1021 + } 1022 + }
+6
crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/richtext.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod facet;
+980
crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/richtext/facet.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: app.bsky.richtext.facet 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + /// Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets. 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 + )] 24 + pub struct ByteSlice<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 25 + pub byte_end: i64, 26 + pub byte_start: i64, 27 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 28 + pub extra_data: core::option::Option< 29 + alloc::collections::BTreeMap< 30 + jacquard_common::deps::smol_str::SmolStr, 31 + jacquard_common::types::value::Data<S>, 32 + >, 33 + >, 34 + } 35 + 36 + /// Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL. 37 + 38 + #[derive( 39 + serde::Serialize, 40 + serde::Deserialize, 41 + Debug, 42 + Clone, 43 + PartialEq, 44 + Eq, 45 + jacquard_derive::IntoStatic 46 + )] 47 + 48 + #[serde( 49 + rename_all = "camelCase", 50 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 51 + )] 52 + pub struct Link<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 53 + pub uri: jacquard_common::types::string::UriValue<S>, 54 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 55 + pub extra_data: core::option::Option< 56 + alloc::collections::BTreeMap< 57 + jacquard_common::deps::smol_str::SmolStr, 58 + jacquard_common::types::value::Data<S>, 59 + >, 60 + >, 61 + } 62 + 63 + /// Annotation of a sub-string within rich text. 64 + 65 + #[derive( 66 + serde::Serialize, 67 + serde::Deserialize, 68 + Debug, 69 + Clone, 70 + PartialEq, 71 + Eq, 72 + jacquard_derive::IntoStatic 73 + )] 74 + 75 + #[serde( 76 + rename_all = "camelCase", 77 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 78 + )] 79 + pub struct Facet<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 80 + pub features: Vec<FacetFeaturesItem<S>>, 81 + pub index: crate::macro_mode::app_bsky::richtext::facet::ByteSlice<S>, 82 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 83 + pub extra_data: core::option::Option< 84 + alloc::collections::BTreeMap< 85 + jacquard_common::deps::smol_str::SmolStr, 86 + jacquard_common::types::value::Data<S>, 87 + >, 88 + >, 89 + } 90 + 91 + 92 + #[jacquard_derive::open_union] 93 + #[derive( 94 + serde::Serialize, 95 + serde::Deserialize, 96 + Debug, 97 + Clone, 98 + PartialEq, 99 + Eq, 100 + jacquard_derive::IntoStatic 101 + )] 102 + 103 + #[serde( 104 + tag = "$type", 105 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 106 + )] 107 + pub enum FacetFeaturesItem<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 108 + #[serde(rename = "app.bsky.richtext.facet#mention")] 109 + Mention(Box<crate::macro_mode::app_bsky::richtext::facet::Mention<S>>), 110 + #[serde(rename = "app.bsky.richtext.facet#link")] 111 + Link(Box<crate::macro_mode::app_bsky::richtext::facet::Link<S>>), 112 + #[serde(rename = "app.bsky.richtext.facet#tag")] 113 + Tag(Box<crate::macro_mode::app_bsky::richtext::facet::Tag<S>>), 114 + } 115 + 116 + /// Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID. 117 + 118 + #[derive( 119 + serde::Serialize, 120 + serde::Deserialize, 121 + Debug, 122 + Clone, 123 + PartialEq, 124 + Eq, 125 + jacquard_derive::IntoStatic 126 + )] 127 + 128 + #[serde( 129 + rename_all = "camelCase", 130 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 131 + )] 132 + pub struct Mention<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 133 + pub did: jacquard_common::types::string::Did<S>, 134 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 135 + pub extra_data: core::option::Option< 136 + alloc::collections::BTreeMap< 137 + jacquard_common::deps::smol_str::SmolStr, 138 + jacquard_common::types::value::Data<S>, 139 + >, 140 + >, 141 + } 142 + 143 + /// Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags'). 144 + 145 + #[derive( 146 + serde::Serialize, 147 + serde::Deserialize, 148 + Debug, 149 + Clone, 150 + PartialEq, 151 + Eq, 152 + jacquard_derive::IntoStatic, 153 + Default 154 + )] 155 + 156 + #[serde( 157 + rename_all = "camelCase", 158 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 159 + )] 160 + pub struct Tag<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 161 + pub tag: S, 162 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 163 + pub extra_data: core::option::Option< 164 + alloc::collections::BTreeMap< 165 + jacquard_common::deps::smol_str::SmolStr, 166 + jacquard_common::types::value::Data<S>, 167 + >, 168 + >, 169 + } 170 + 171 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 172 + for ByteSlice<S> { 173 + fn nsid() -> &'static str { 174 + "app.bsky.richtext.facet" 175 + } 176 + fn def_name() -> &'static str { 177 + "byteSlice" 178 + } 179 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 180 + lexicon_doc_app_bsky_richtext_facet() 181 + } 182 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 183 + { 184 + let value = &self.byte_end; 185 + if *value < 0i64 { 186 + return Err(jacquard_lexicon::validation::ConstraintError::Minimum { 187 + path: jacquard_lexicon::validation::ValidationPath::from_field( 188 + "byte_end", 189 + ), 190 + min: 0i64, 191 + actual: *value, 192 + }); 193 + } 194 + } 195 + { 196 + let value = &self.byte_start; 197 + if *value < 0i64 { 198 + return Err(jacquard_lexicon::validation::ConstraintError::Minimum { 199 + path: jacquard_lexicon::validation::ValidationPath::from_field( 200 + "byte_start", 201 + ), 202 + min: 0i64, 203 + actual: *value, 204 + }); 205 + } 206 + } 207 + Ok(()) 208 + } 209 + } 210 + 211 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Link<S> { 212 + fn nsid() -> &'static str { 213 + "app.bsky.richtext.facet" 214 + } 215 + fn def_name() -> &'static str { 216 + "link" 217 + } 218 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 219 + lexicon_doc_app_bsky_richtext_facet() 220 + } 221 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 222 + Ok(()) 223 + } 224 + } 225 + 226 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Facet<S> { 227 + fn nsid() -> &'static str { 228 + "app.bsky.richtext.facet" 229 + } 230 + fn def_name() -> &'static str { 231 + "main" 232 + } 233 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 234 + lexicon_doc_app_bsky_richtext_facet() 235 + } 236 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 237 + Ok(()) 238 + } 239 + } 240 + 241 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Mention<S> { 242 + fn nsid() -> &'static str { 243 + "app.bsky.richtext.facet" 244 + } 245 + fn def_name() -> &'static str { 246 + "mention" 247 + } 248 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 249 + lexicon_doc_app_bsky_richtext_facet() 250 + } 251 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 252 + Ok(()) 253 + } 254 + } 255 + 256 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Tag<S> { 257 + fn nsid() -> &'static str { 258 + "app.bsky.richtext.facet" 259 + } 260 + fn def_name() -> &'static str { 261 + "tag" 262 + } 263 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 264 + lexicon_doc_app_bsky_richtext_facet() 265 + } 266 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 267 + { 268 + let value = &self.tag; 269 + #[allow(unused_comparisons)] 270 + if <str>::len(value.as_ref()) > 640usize { 271 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 272 + path: jacquard_lexicon::validation::ValidationPath::from_field( 273 + "tag", 274 + ), 275 + max: 640usize, 276 + actual: <str>::len(value.as_ref()), 277 + }); 278 + } 279 + } 280 + { 281 + let value = &self.tag; 282 + { 283 + let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes( 284 + value.as_ref(), 285 + true, 286 + ) 287 + .count(); 288 + if count > 64usize { 289 + return Err(jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 290 + path: jacquard_lexicon::validation::ValidationPath::from_field( 291 + "tag", 292 + ), 293 + max: 64usize, 294 + actual: count, 295 + }); 296 + } 297 + } 298 + } 299 + Ok(()) 300 + } 301 + } 302 + 303 + pub mod byte_slice_state { 304 + 305 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 306 + #[allow(unused)] 307 + use ::core::marker::PhantomData; 308 + mod sealed { 309 + pub trait Sealed {} 310 + } 311 + /// State trait tracking which required fields have been set 312 + pub trait State: sealed::Sealed { 313 + type ByteEnd; 314 + type ByteStart; 315 + } 316 + /// Empty state - all required fields are unset 317 + pub struct Empty(()); 318 + impl sealed::Sealed for Empty {} 319 + impl State for Empty { 320 + type ByteEnd = Unset; 321 + type ByteStart = Unset; 322 + } 323 + ///State transition - sets the `byte_end` field to Set 324 + pub struct SetByteEnd<St: State = Empty>(PhantomData<fn() -> St>); 325 + impl<St: State> sealed::Sealed for SetByteEnd<St> {} 326 + impl<St: State> State for SetByteEnd<St> { 327 + type ByteEnd = Set<members::byte_end>; 328 + type ByteStart = St::ByteStart; 329 + } 330 + ///State transition - sets the `byte_start` field to Set 331 + pub struct SetByteStart<St: State = Empty>(PhantomData<fn() -> St>); 332 + impl<St: State> sealed::Sealed for SetByteStart<St> {} 333 + impl<St: State> State for SetByteStart<St> { 334 + type ByteEnd = St::ByteEnd; 335 + type ByteStart = Set<members::byte_start>; 336 + } 337 + /// Marker types for field names 338 + #[allow(non_camel_case_types)] 339 + pub mod members { 340 + ///Marker type for the `byte_end` field 341 + pub struct byte_end(()); 342 + ///Marker type for the `byte_start` field 343 + pub struct byte_start(()); 344 + } 345 + } 346 + 347 + /// Builder for constructing an instance of this type. 348 + pub struct ByteSliceBuilder<S: jacquard_common::BosStr, St: byte_slice_state::State> { 349 + _state: ::core::marker::PhantomData<fn() -> St>, 350 + _fields: (core::option::Option<i64>, core::option::Option<i64>), 351 + _type: ::core::marker::PhantomData<fn() -> S>, 352 + } 353 + 354 + impl<S: jacquard_common::BosStr> ByteSlice<S> { 355 + /// Create a new builder for this type. 356 + pub fn new() -> ByteSliceBuilder<S, byte_slice_state::Empty> { 357 + ByteSliceBuilder::new() 358 + } 359 + } 360 + 361 + impl<S: jacquard_common::BosStr> ByteSliceBuilder<S, byte_slice_state::Empty> { 362 + /// Create a new builder with all fields unset. 363 + pub fn new() -> Self { 364 + ByteSliceBuilder { 365 + _state: ::core::marker::PhantomData, 366 + _fields: (None, None), 367 + _type: ::core::marker::PhantomData, 368 + } 369 + } 370 + } 371 + 372 + impl<S: jacquard_common::BosStr, St> ByteSliceBuilder<S, St> 373 + where 374 + St: byte_slice_state::State, 375 + St::ByteEnd: byte_slice_state::IsUnset, 376 + { 377 + /// Set the `byteEnd` field (required) 378 + pub fn byte_end( 379 + mut self, 380 + value: impl Into<i64>, 381 + ) -> ByteSliceBuilder<S, byte_slice_state::SetByteEnd<St>> { 382 + self._fields.0 = ::core::option::Option::Some(value.into()); 383 + ByteSliceBuilder { 384 + _state: ::core::marker::PhantomData, 385 + _fields: self._fields, 386 + _type: ::core::marker::PhantomData, 387 + } 388 + } 389 + } 390 + 391 + impl<S: jacquard_common::BosStr, St> ByteSliceBuilder<S, St> 392 + where 393 + St: byte_slice_state::State, 394 + St::ByteStart: byte_slice_state::IsUnset, 395 + { 396 + /// Set the `byteStart` field (required) 397 + pub fn byte_start( 398 + mut self, 399 + value: impl Into<i64>, 400 + ) -> ByteSliceBuilder<S, byte_slice_state::SetByteStart<St>> { 401 + self._fields.1 = ::core::option::Option::Some(value.into()); 402 + ByteSliceBuilder { 403 + _state: ::core::marker::PhantomData, 404 + _fields: self._fields, 405 + _type: ::core::marker::PhantomData, 406 + } 407 + } 408 + } 409 + 410 + impl<S: jacquard_common::BosStr, St> ByteSliceBuilder<S, St> 411 + where 412 + St: byte_slice_state::State, 413 + St::ByteEnd: byte_slice_state::IsSet, 414 + St::ByteStart: byte_slice_state::IsSet, 415 + { 416 + /// Build the final struct. 417 + pub fn build(self) -> ByteSlice<S> { 418 + ByteSlice { 419 + byte_end: self._fields.0.unwrap(), 420 + byte_start: self._fields.1.unwrap(), 421 + extra_data: Default::default(), 422 + } 423 + } 424 + /// Build the final struct with custom extra_data. 425 + pub fn build_with_data( 426 + self, 427 + extra_data: alloc::collections::BTreeMap< 428 + jacquard_common::deps::smol_str::SmolStr, 429 + jacquard_common::types::value::Data<S>, 430 + >, 431 + ) -> ByteSlice<S> { 432 + ByteSlice { 433 + byte_end: self._fields.0.unwrap(), 434 + byte_start: self._fields.1.unwrap(), 435 + extra_data: Some(extra_data), 436 + } 437 + } 438 + } 439 + 440 + fn lexicon_doc_app_bsky_richtext_facet() -> jacquard_lexicon::lexicon::LexiconDoc< 441 + 'static, 442 + > { 443 + ::jacquard_lexicon::lexicon::LexiconDoc { 444 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 445 + id: ::jacquard_common::CowStr::new_static("app.bsky.richtext.facet"), 446 + defs: { 447 + let mut map = ::alloc::collections::BTreeMap::new(); 448 + map.insert( 449 + ::jacquard_common::deps::smol_str::SmolStr::new_static("byteSlice"), 450 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 451 + description: Some( 452 + ::jacquard_common::CowStr::new_static( 453 + "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.", 454 + ), 455 + ), 456 + required: Some( 457 + vec![ 458 + ::jacquard_common::deps::smol_str::SmolStr::new_static("byteStart"), 459 + ::jacquard_common::deps::smol_str::SmolStr::new_static("byteEnd") 460 + ], 461 + ), 462 + properties: { 463 + #[allow(unused_mut)] 464 + let mut map = ::alloc::collections::BTreeMap::new(); 465 + map.insert( 466 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 467 + "byteEnd", 468 + ), 469 + ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 470 + minimum: Some(0i64), 471 + ..Default::default() 472 + }), 473 + ); 474 + map.insert( 475 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 476 + "byteStart", 477 + ), 478 + ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 479 + minimum: Some(0i64), 480 + ..Default::default() 481 + }), 482 + ); 483 + map 484 + }, 485 + ..Default::default() 486 + }), 487 + ); 488 + map.insert( 489 + ::jacquard_common::deps::smol_str::SmolStr::new_static("link"), 490 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 491 + description: Some( 492 + ::jacquard_common::CowStr::new_static( 493 + "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.", 494 + ), 495 + ), 496 + required: Some( 497 + vec![ 498 + ::jacquard_common::deps::smol_str::SmolStr::new_static("uri") 499 + ], 500 + ), 501 + properties: { 502 + #[allow(unused_mut)] 503 + let mut map = ::alloc::collections::BTreeMap::new(); 504 + map.insert( 505 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 506 + "uri", 507 + ), 508 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 509 + format: Some( 510 + ::jacquard_lexicon::lexicon::LexStringFormat::Uri, 511 + ), 512 + ..Default::default() 513 + }), 514 + ); 515 + map 516 + }, 517 + ..Default::default() 518 + }), 519 + ); 520 + map.insert( 521 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 522 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 523 + description: Some( 524 + ::jacquard_common::CowStr::new_static( 525 + "Annotation of a sub-string within rich text.", 526 + ), 527 + ), 528 + required: Some( 529 + vec![ 530 + ::jacquard_common::deps::smol_str::SmolStr::new_static("index"), 531 + ::jacquard_common::deps::smol_str::SmolStr::new_static("features") 532 + ], 533 + ), 534 + properties: { 535 + #[allow(unused_mut)] 536 + let mut map = ::alloc::collections::BTreeMap::new(); 537 + map.insert( 538 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 539 + "features", 540 + ), 541 + ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 542 + items: ::jacquard_lexicon::lexicon::LexArrayItem::Union(::jacquard_lexicon::lexicon::LexRefUnion { 543 + refs: vec![ 544 + ::jacquard_common::CowStr::new_static("#mention"), 545 + ::jacquard_common::CowStr::new_static("#link"), 546 + ::jacquard_common::CowStr::new_static("#tag") 547 + ], 548 + ..Default::default() 549 + }), 550 + ..Default::default() 551 + }), 552 + ); 553 + map.insert( 554 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 555 + "index", 556 + ), 557 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 558 + r#ref: ::jacquard_common::CowStr::new_static("#byteSlice"), 559 + ..Default::default() 560 + }), 561 + ); 562 + map 563 + }, 564 + ..Default::default() 565 + }), 566 + ); 567 + map.insert( 568 + ::jacquard_common::deps::smol_str::SmolStr::new_static("mention"), 569 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 570 + description: Some( 571 + ::jacquard_common::CowStr::new_static( 572 + "Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.", 573 + ), 574 + ), 575 + required: Some( 576 + vec![ 577 + ::jacquard_common::deps::smol_str::SmolStr::new_static("did") 578 + ], 579 + ), 580 + properties: { 581 + #[allow(unused_mut)] 582 + let mut map = ::alloc::collections::BTreeMap::new(); 583 + map.insert( 584 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 585 + "did", 586 + ), 587 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 588 + format: Some( 589 + ::jacquard_lexicon::lexicon::LexStringFormat::Did, 590 + ), 591 + ..Default::default() 592 + }), 593 + ); 594 + map 595 + }, 596 + ..Default::default() 597 + }), 598 + ); 599 + map.insert( 600 + ::jacquard_common::deps::smol_str::SmolStr::new_static("tag"), 601 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 602 + description: Some( 603 + ::jacquard_common::CowStr::new_static( 604 + "Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').", 605 + ), 606 + ), 607 + required: Some( 608 + vec![ 609 + ::jacquard_common::deps::smol_str::SmolStr::new_static("tag") 610 + ], 611 + ), 612 + properties: { 613 + #[allow(unused_mut)] 614 + let mut map = ::alloc::collections::BTreeMap::new(); 615 + map.insert( 616 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 617 + "tag", 618 + ), 619 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 620 + max_length: Some(640usize), 621 + max_graphemes: Some(64usize), 622 + ..Default::default() 623 + }), 624 + ); 625 + map 626 + }, 627 + ..Default::default() 628 + }), 629 + ); 630 + map 631 + }, 632 + ..Default::default() 633 + } 634 + } 635 + 636 + pub mod link_state { 637 + 638 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 639 + #[allow(unused)] 640 + use ::core::marker::PhantomData; 641 + mod sealed { 642 + pub trait Sealed {} 643 + } 644 + /// State trait tracking which required fields have been set 645 + pub trait State: sealed::Sealed { 646 + type Uri; 647 + } 648 + /// Empty state - all required fields are unset 649 + pub struct Empty(()); 650 + impl sealed::Sealed for Empty {} 651 + impl State for Empty { 652 + type Uri = Unset; 653 + } 654 + ///State transition - sets the `uri` field to Set 655 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 656 + impl<St: State> sealed::Sealed for SetUri<St> {} 657 + impl<St: State> State for SetUri<St> { 658 + type Uri = Set<members::uri>; 659 + } 660 + /// Marker types for field names 661 + #[allow(non_camel_case_types)] 662 + pub mod members { 663 + ///Marker type for the `uri` field 664 + pub struct uri(()); 665 + } 666 + } 667 + 668 + /// Builder for constructing an instance of this type. 669 + pub struct LinkBuilder<S: jacquard_common::BosStr, St: link_state::State> { 670 + _state: ::core::marker::PhantomData<fn() -> St>, 671 + _fields: (core::option::Option<jacquard_common::types::string::UriValue<S>>,), 672 + _type: ::core::marker::PhantomData<fn() -> S>, 673 + } 674 + 675 + impl<S: jacquard_common::BosStr> Link<S> { 676 + /// Create a new builder for this type. 677 + pub fn new() -> LinkBuilder<S, link_state::Empty> { 678 + LinkBuilder::new() 679 + } 680 + } 681 + 682 + impl<S: jacquard_common::BosStr> LinkBuilder<S, link_state::Empty> { 683 + /// Create a new builder with all fields unset. 684 + pub fn new() -> Self { 685 + LinkBuilder { 686 + _state: ::core::marker::PhantomData, 687 + _fields: (None,), 688 + _type: ::core::marker::PhantomData, 689 + } 690 + } 691 + } 692 + 693 + impl<S: jacquard_common::BosStr, St> LinkBuilder<S, St> 694 + where 695 + St: link_state::State, 696 + St::Uri: link_state::IsUnset, 697 + { 698 + /// Set the `uri` field (required) 699 + pub fn uri( 700 + mut self, 701 + value: impl Into<jacquard_common::types::string::UriValue<S>>, 702 + ) -> LinkBuilder<S, link_state::SetUri<St>> { 703 + self._fields.0 = ::core::option::Option::Some(value.into()); 704 + LinkBuilder { 705 + _state: ::core::marker::PhantomData, 706 + _fields: self._fields, 707 + _type: ::core::marker::PhantomData, 708 + } 709 + } 710 + } 711 + 712 + impl<S: jacquard_common::BosStr, St> LinkBuilder<S, St> 713 + where 714 + St: link_state::State, 715 + St::Uri: link_state::IsSet, 716 + { 717 + /// Build the final struct. 718 + pub fn build(self) -> Link<S> { 719 + Link { 720 + uri: self._fields.0.unwrap(), 721 + extra_data: Default::default(), 722 + } 723 + } 724 + /// Build the final struct with custom extra_data. 725 + pub fn build_with_data( 726 + self, 727 + extra_data: alloc::collections::BTreeMap< 728 + jacquard_common::deps::smol_str::SmolStr, 729 + jacquard_common::types::value::Data<S>, 730 + >, 731 + ) -> Link<S> { 732 + Link { 733 + uri: self._fields.0.unwrap(), 734 + extra_data: Some(extra_data), 735 + } 736 + } 737 + } 738 + 739 + pub mod facet_state { 740 + 741 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 742 + #[allow(unused)] 743 + use ::core::marker::PhantomData; 744 + mod sealed { 745 + pub trait Sealed {} 746 + } 747 + /// State trait tracking which required fields have been set 748 + pub trait State: sealed::Sealed { 749 + type Features; 750 + type Index; 751 + } 752 + /// Empty state - all required fields are unset 753 + pub struct Empty(()); 754 + impl sealed::Sealed for Empty {} 755 + impl State for Empty { 756 + type Features = Unset; 757 + type Index = Unset; 758 + } 759 + ///State transition - sets the `features` field to Set 760 + pub struct SetFeatures<St: State = Empty>(PhantomData<fn() -> St>); 761 + impl<St: State> sealed::Sealed for SetFeatures<St> {} 762 + impl<St: State> State for SetFeatures<St> { 763 + type Features = Set<members::features>; 764 + type Index = St::Index; 765 + } 766 + ///State transition - sets the `index` field to Set 767 + pub struct SetIndex<St: State = Empty>(PhantomData<fn() -> St>); 768 + impl<St: State> sealed::Sealed for SetIndex<St> {} 769 + impl<St: State> State for SetIndex<St> { 770 + type Features = St::Features; 771 + type Index = Set<members::index>; 772 + } 773 + /// Marker types for field names 774 + #[allow(non_camel_case_types)] 775 + pub mod members { 776 + ///Marker type for the `features` field 777 + pub struct features(()); 778 + ///Marker type for the `index` field 779 + pub struct index(()); 780 + } 781 + } 782 + 783 + /// Builder for constructing an instance of this type. 784 + pub struct FacetBuilder<S: jacquard_common::BosStr, St: facet_state::State> { 785 + _state: ::core::marker::PhantomData<fn() -> St>, 786 + _fields: ( 787 + core::option::Option<Vec<FacetFeaturesItem<S>>>, 788 + core::option::Option<crate::macro_mode::app_bsky::richtext::facet::ByteSlice<S>>, 789 + ), 790 + _type: ::core::marker::PhantomData<fn() -> S>, 791 + } 792 + 793 + impl<S: jacquard_common::BosStr> Facet<S> { 794 + /// Create a new builder for this type. 795 + pub fn new() -> FacetBuilder<S, facet_state::Empty> { 796 + FacetBuilder::new() 797 + } 798 + } 799 + 800 + impl<S: jacquard_common::BosStr> FacetBuilder<S, facet_state::Empty> { 801 + /// Create a new builder with all fields unset. 802 + pub fn new() -> Self { 803 + FacetBuilder { 804 + _state: ::core::marker::PhantomData, 805 + _fields: (None, None), 806 + _type: ::core::marker::PhantomData, 807 + } 808 + } 809 + } 810 + 811 + impl<S: jacquard_common::BosStr, St> FacetBuilder<S, St> 812 + where 813 + St: facet_state::State, 814 + St::Features: facet_state::IsUnset, 815 + { 816 + /// Set the `features` field (required) 817 + pub fn features( 818 + mut self, 819 + value: impl Into<Vec<FacetFeaturesItem<S>>>, 820 + ) -> FacetBuilder<S, facet_state::SetFeatures<St>> { 821 + self._fields.0 = ::core::option::Option::Some(value.into()); 822 + FacetBuilder { 823 + _state: ::core::marker::PhantomData, 824 + _fields: self._fields, 825 + _type: ::core::marker::PhantomData, 826 + } 827 + } 828 + } 829 + 830 + impl<S: jacquard_common::BosStr, St> FacetBuilder<S, St> 831 + where 832 + St: facet_state::State, 833 + St::Index: facet_state::IsUnset, 834 + { 835 + /// Set the `index` field (required) 836 + pub fn index( 837 + mut self, 838 + value: impl Into<crate::macro_mode::app_bsky::richtext::facet::ByteSlice<S>>, 839 + ) -> FacetBuilder<S, facet_state::SetIndex<St>> { 840 + self._fields.1 = ::core::option::Option::Some(value.into()); 841 + FacetBuilder { 842 + _state: ::core::marker::PhantomData, 843 + _fields: self._fields, 844 + _type: ::core::marker::PhantomData, 845 + } 846 + } 847 + } 848 + 849 + impl<S: jacquard_common::BosStr, St> FacetBuilder<S, St> 850 + where 851 + St: facet_state::State, 852 + St::Features: facet_state::IsSet, 853 + St::Index: facet_state::IsSet, 854 + { 855 + /// Build the final struct. 856 + pub fn build(self) -> Facet<S> { 857 + Facet { 858 + features: self._fields.0.unwrap(), 859 + index: self._fields.1.unwrap(), 860 + extra_data: Default::default(), 861 + } 862 + } 863 + /// Build the final struct with custom extra_data. 864 + pub fn build_with_data( 865 + self, 866 + extra_data: alloc::collections::BTreeMap< 867 + jacquard_common::deps::smol_str::SmolStr, 868 + jacquard_common::types::value::Data<S>, 869 + >, 870 + ) -> Facet<S> { 871 + Facet { 872 + features: self._fields.0.unwrap(), 873 + index: self._fields.1.unwrap(), 874 + extra_data: Some(extra_data), 875 + } 876 + } 877 + } 878 + 879 + pub mod mention_state { 880 + 881 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 882 + #[allow(unused)] 883 + use ::core::marker::PhantomData; 884 + mod sealed { 885 + pub trait Sealed {} 886 + } 887 + /// State trait tracking which required fields have been set 888 + pub trait State: sealed::Sealed { 889 + type Did; 890 + } 891 + /// Empty state - all required fields are unset 892 + pub struct Empty(()); 893 + impl sealed::Sealed for Empty {} 894 + impl State for Empty { 895 + type Did = Unset; 896 + } 897 + ///State transition - sets the `did` field to Set 898 + pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>); 899 + impl<St: State> sealed::Sealed for SetDid<St> {} 900 + impl<St: State> State for SetDid<St> { 901 + type Did = Set<members::did>; 902 + } 903 + /// Marker types for field names 904 + #[allow(non_camel_case_types)] 905 + pub mod members { 906 + ///Marker type for the `did` field 907 + pub struct did(()); 908 + } 909 + } 910 + 911 + /// Builder for constructing an instance of this type. 912 + pub struct MentionBuilder<S: jacquard_common::BosStr, St: mention_state::State> { 913 + _state: ::core::marker::PhantomData<fn() -> St>, 914 + _fields: (core::option::Option<jacquard_common::types::string::Did<S>>,), 915 + _type: ::core::marker::PhantomData<fn() -> S>, 916 + } 917 + 918 + impl<S: jacquard_common::BosStr> Mention<S> { 919 + /// Create a new builder for this type. 920 + pub fn new() -> MentionBuilder<S, mention_state::Empty> { 921 + MentionBuilder::new() 922 + } 923 + } 924 + 925 + impl<S: jacquard_common::BosStr> MentionBuilder<S, mention_state::Empty> { 926 + /// Create a new builder with all fields unset. 927 + pub fn new() -> Self { 928 + MentionBuilder { 929 + _state: ::core::marker::PhantomData, 930 + _fields: (None,), 931 + _type: ::core::marker::PhantomData, 932 + } 933 + } 934 + } 935 + 936 + impl<S: jacquard_common::BosStr, St> MentionBuilder<S, St> 937 + where 938 + St: mention_state::State, 939 + St::Did: mention_state::IsUnset, 940 + { 941 + /// Set the `did` field (required) 942 + pub fn did( 943 + mut self, 944 + value: impl Into<jacquard_common::types::string::Did<S>>, 945 + ) -> MentionBuilder<S, mention_state::SetDid<St>> { 946 + self._fields.0 = ::core::option::Option::Some(value.into()); 947 + MentionBuilder { 948 + _state: ::core::marker::PhantomData, 949 + _fields: self._fields, 950 + _type: ::core::marker::PhantomData, 951 + } 952 + } 953 + } 954 + 955 + impl<S: jacquard_common::BosStr, St> MentionBuilder<S, St> 956 + where 957 + St: mention_state::State, 958 + St::Did: mention_state::IsSet, 959 + { 960 + /// Build the final struct. 961 + pub fn build(self) -> Mention<S> { 962 + Mention { 963 + did: self._fields.0.unwrap(), 964 + extra_data: Default::default(), 965 + } 966 + } 967 + /// Build the final struct with custom extra_data. 968 + pub fn build_with_data( 969 + self, 970 + extra_data: alloc::collections::BTreeMap< 971 + jacquard_common::deps::smol_str::SmolStr, 972 + jacquard_common::types::value::Data<S>, 973 + >, 974 + ) -> Mention<S> { 975 + Mention { 976 + did: self._fields.0.unwrap(), 977 + extra_data: Some(extra_data), 978 + } 979 + } 980 + }
+45
crates/jacquard-codegen-tests/src/generated/macro_mode/builder_types.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + /// Marker type indicating a builder field has been set 7 + pub struct Set<T>(pub T); 8 + impl<T> Set<T> { 9 + /// Extract the inner value 10 + #[inline] 11 + pub fn into_inner(self) -> T { 12 + self.0 13 + } 14 + } 15 + 16 + /// Marker type indicating a builder field has not been set 17 + pub struct Unset; 18 + /// Trait indicating a builder field is set (has a value) 19 + 20 + #[jacquard_common::deps::codegen::rustversion::attr( 21 + since(1.78.0), 22 + diagnostic::on_unimplemented( 23 + message = "the field `{Self}` was not set, but this method requires it to be set", 24 + label = "the field `{Self}` was not set" 25 + ) 26 + )] 27 + pub trait IsSet: private::Sealed {} 28 + /// Trait indicating a builder field is unset (no value yet) 29 + 30 + #[jacquard_common::deps::codegen::rustversion::attr( 31 + since(1.78.0), 32 + diagnostic::on_unimplemented( 33 + message = "the field `{Self}` was already set, but this method requires it to be unset", 34 + label = "the field `{Self}` was already set" 35 + ) 36 + )] 37 + pub trait IsUnset: private::Sealed {} 38 + impl<T> IsSet for Set<T> {} 39 + impl IsUnset for Unset {} 40 + mod private { 41 + /// Sealed trait to prevent external implementations 42 + pub trait Sealed {} 43 + impl<T> Sealed for super::Set<T> {} 44 + impl Sealed for super::Unset {} 45 + }
+7
crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod label; 7 + pub mod repo;
+2077
crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/label.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: com.atproto.label.defs 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + /// Metadata tag on an atproto resource (eg, repo or record). 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 + )] 24 + pub struct Label<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 25 + ///Optionally, CID specifying the specific version of 'uri' resource this label applies to. 26 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 27 + pub cid: core::option::Option<jacquard_common::types::string::Cid<S>>, 28 + ///Timestamp when this label was created. 29 + pub cts: jacquard_common::types::string::Datetime, 30 + ///Timestamp at which this label expires (no longer applies). 31 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 32 + pub exp: core::option::Option<jacquard_common::types::string::Datetime>, 33 + ///If true, this is a negation label, overwriting a previous label. 34 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 35 + pub neg: core::option::Option<bool>, 36 + ///Signature of dag-cbor encoded label. 37 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 38 + #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")] 39 + pub sig: core::option::Option<jacquard_common::deps::bytes::Bytes>, 40 + ///DID of the actor who created this label. 41 + pub src: jacquard_common::types::string::Did<S>, 42 + ///AT URI of the record, repository (account), or other resource that this label applies to. 43 + pub uri: jacquard_common::types::string::UriValue<S>, 44 + ///The short string name of the value or type of this label. 45 + pub val: S, 46 + ///The AT Protocol version of the label object. 47 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 48 + pub ver: core::option::Option<i64>, 49 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 50 + pub extra_data: core::option::Option< 51 + alloc::collections::BTreeMap< 52 + jacquard_common::deps::smol_str::SmolStr, 53 + jacquard_common::types::value::Data<S>, 54 + >, 55 + >, 56 + } 57 + 58 + 59 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 60 + pub enum LabelValue<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 61 + Hide, 62 + NoPromote, 63 + Warn, 64 + NoUnauthenticated, 65 + DmcaViolation, 66 + Doxxing, 67 + Porn, 68 + Sexual, 69 + Nudity, 70 + Nsfl, 71 + Gore, 72 + Other(S), 73 + } 74 + 75 + impl<S: jacquard_common::BosStr> LabelValue<S> { 76 + pub fn as_str(&self) -> &str { 77 + match self { 78 + Self::Hide => "!hide", 79 + Self::NoPromote => "!no-promote", 80 + Self::Warn => "!warn", 81 + Self::NoUnauthenticated => "!no-unauthenticated", 82 + Self::DmcaViolation => "dmca-violation", 83 + Self::Doxxing => "doxxing", 84 + Self::Porn => "porn", 85 + Self::Sexual => "sexual", 86 + Self::Nudity => "nudity", 87 + Self::Nsfl => "nsfl", 88 + Self::Gore => "gore", 89 + Self::Other(s) => s.as_ref(), 90 + } 91 + } 92 + /// Construct from a string-like value, matching known values. 93 + pub fn from_value(s: S) -> Self { 94 + match s.as_ref() { 95 + "!hide" => Self::Hide, 96 + "!no-promote" => Self::NoPromote, 97 + "!warn" => Self::Warn, 98 + "!no-unauthenticated" => Self::NoUnauthenticated, 99 + "dmca-violation" => Self::DmcaViolation, 100 + "doxxing" => Self::Doxxing, 101 + "porn" => Self::Porn, 102 + "sexual" => Self::Sexual, 103 + "nudity" => Self::Nudity, 104 + "nsfl" => Self::Nsfl, 105 + "gore" => Self::Gore, 106 + _ => Self::Other(s), 107 + } 108 + } 109 + } 110 + 111 + impl<S: jacquard_common::BosStr> AsRef<str> for LabelValue<S> { 112 + fn as_ref(&self) -> &str { 113 + self.as_str() 114 + } 115 + } 116 + 117 + impl<S: jacquard_common::BosStr> core::fmt::Display for LabelValue<S> { 118 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 119 + write!(f, "{}", self.as_str()) 120 + } 121 + } 122 + 123 + impl<S: jacquard_common::BosStr> serde::Serialize for LabelValue<S> { 124 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 125 + where 126 + Ser: serde::Serializer, 127 + { 128 + serializer.serialize_str(self.as_str()) 129 + } 130 + } 131 + 132 + impl<'de, S: serde::Deserialize<'de> + jacquard_common::BosStr> serde::Deserialize<'de> 133 + for LabelValue<S> { 134 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 135 + where 136 + D: serde::Deserializer<'de>, 137 + { 138 + let s = S::deserialize(deserializer)?; 139 + Ok(Self::from_value(s)) 140 + } 141 + } 142 + 143 + impl<S: jacquard_common::BosStr> jacquard_common::IntoStatic for LabelValue<S> 144 + where 145 + S: jacquard_common::BosStr + jacquard_common::IntoStatic, 146 + S::Output: jacquard_common::BosStr, 147 + { 148 + type Output = LabelValue<S::Output>; 149 + fn into_static(self) -> Self::Output { 150 + match self { 151 + LabelValue::Hide => LabelValue::Hide, 152 + LabelValue::NoPromote => LabelValue::NoPromote, 153 + LabelValue::Warn => LabelValue::Warn, 154 + LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated, 155 + LabelValue::DmcaViolation => LabelValue::DmcaViolation, 156 + LabelValue::Doxxing => LabelValue::Doxxing, 157 + LabelValue::Porn => LabelValue::Porn, 158 + LabelValue::Sexual => LabelValue::Sexual, 159 + LabelValue::Nudity => LabelValue::Nudity, 160 + LabelValue::Nsfl => LabelValue::Nsfl, 161 + LabelValue::Gore => LabelValue::Gore, 162 + LabelValue::Other(v) => LabelValue::Other(v.into_static()), 163 + } 164 + } 165 + } 166 + 167 + /// Declares a label value and its expected interpretations and behaviors. 168 + 169 + #[derive( 170 + serde::Serialize, 171 + serde::Deserialize, 172 + Debug, 173 + Clone, 174 + PartialEq, 175 + Eq, 176 + jacquard_derive::IntoStatic 177 + )] 178 + 179 + #[serde( 180 + rename_all = "camelCase", 181 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 182 + )] 183 + pub struct LabelValueDefinition< 184 + S: jacquard_common::BosStr = jacquard_common::DefaultStr, 185 + > { 186 + ///Does the user need to have adult content enabled in order to configure this label? 187 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 188 + pub adult_only: core::option::Option<bool>, 189 + ///What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing. 190 + pub blurs: LabelValueDefinitionBlurs<S>, 191 + ///The default setting for this label. 192 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 193 + pub default_setting: core::option::Option<LabelValueDefinitionDefaultSetting<S>>, 194 + ///The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+). 195 + pub identifier: S, 196 + pub locales: Vec< 197 + crate::macro_mode::com_atproto::label::LabelValueDefinitionStrings<S>, 198 + >, 199 + ///How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. 200 + pub severity: LabelValueDefinitionSeverity<S>, 201 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 202 + pub extra_data: core::option::Option< 203 + alloc::collections::BTreeMap< 204 + jacquard_common::deps::smol_str::SmolStr, 205 + jacquard_common::types::value::Data<S>, 206 + >, 207 + >, 208 + } 209 + 210 + /// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing. 211 + 212 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 213 + pub enum LabelValueDefinitionBlurs< 214 + S: jacquard_common::BosStr = jacquard_common::DefaultStr, 215 + > { 216 + Content, 217 + Media, 218 + None, 219 + Other(S), 220 + } 221 + 222 + impl<S: jacquard_common::BosStr> LabelValueDefinitionBlurs<S> { 223 + pub fn as_str(&self) -> &str { 224 + match self { 225 + Self::Content => "content", 226 + Self::Media => "media", 227 + Self::None => "none", 228 + Self::Other(s) => s.as_ref(), 229 + } 230 + } 231 + /// Construct from a string-like value, matching known values. 232 + pub fn from_value(s: S) -> Self { 233 + match s.as_ref() { 234 + "content" => Self::Content, 235 + "media" => Self::Media, 236 + "none" => Self::None, 237 + _ => Self::Other(s), 238 + } 239 + } 240 + } 241 + 242 + impl<S: jacquard_common::BosStr> core::fmt::Display for LabelValueDefinitionBlurs<S> { 243 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 244 + write!(f, "{}", self.as_str()) 245 + } 246 + } 247 + 248 + impl<S: jacquard_common::BosStr> AsRef<str> for LabelValueDefinitionBlurs<S> { 249 + fn as_ref(&self) -> &str { 250 + self.as_str() 251 + } 252 + } 253 + 254 + impl<S: jacquard_common::BosStr> serde::Serialize for LabelValueDefinitionBlurs<S> { 255 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 256 + where 257 + Ser: serde::Serializer, 258 + { 259 + serializer.serialize_str(self.as_str()) 260 + } 261 + } 262 + 263 + impl<'de, S: serde::Deserialize<'de> + jacquard_common::BosStr> serde::Deserialize<'de> 264 + for LabelValueDefinitionBlurs<S> { 265 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 266 + where 267 + D: serde::Deserializer<'de>, 268 + { 269 + let s = S::deserialize(deserializer)?; 270 + Ok(Self::from_value(s)) 271 + } 272 + } 273 + 274 + impl<S: jacquard_common::BosStr + Default> Default for LabelValueDefinitionBlurs<S> { 275 + fn default() -> Self { 276 + Self::Other(Default::default()) 277 + } 278 + } 279 + 280 + impl<S: jacquard_common::BosStr> jacquard_common::IntoStatic 281 + for LabelValueDefinitionBlurs<S> 282 + where 283 + S: jacquard_common::BosStr + jacquard_common::IntoStatic, 284 + S::Output: jacquard_common::BosStr, 285 + { 286 + type Output = LabelValueDefinitionBlurs<S::Output>; 287 + fn into_static(self) -> Self::Output { 288 + match self { 289 + LabelValueDefinitionBlurs::Content => LabelValueDefinitionBlurs::Content, 290 + LabelValueDefinitionBlurs::Media => LabelValueDefinitionBlurs::Media, 291 + LabelValueDefinitionBlurs::None => LabelValueDefinitionBlurs::None, 292 + LabelValueDefinitionBlurs::Other(v) => { 293 + LabelValueDefinitionBlurs::Other(v.into_static()) 294 + } 295 + } 296 + } 297 + } 298 + 299 + /// The default setting for this label. 300 + 301 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 302 + pub enum LabelValueDefinitionDefaultSetting< 303 + S: jacquard_common::BosStr = jacquard_common::DefaultStr, 304 + > { 305 + Ignore, 306 + Warn, 307 + Hide, 308 + Other(S), 309 + } 310 + 311 + impl<S: jacquard_common::BosStr> LabelValueDefinitionDefaultSetting<S> { 312 + pub fn as_str(&self) -> &str { 313 + match self { 314 + Self::Ignore => "ignore", 315 + Self::Warn => "warn", 316 + Self::Hide => "hide", 317 + Self::Other(s) => s.as_ref(), 318 + } 319 + } 320 + /// Construct from a string-like value, matching known values. 321 + pub fn from_value(s: S) -> Self { 322 + match s.as_ref() { 323 + "ignore" => Self::Ignore, 324 + "warn" => Self::Warn, 325 + "hide" => Self::Hide, 326 + _ => Self::Other(s), 327 + } 328 + } 329 + } 330 + 331 + impl<S: jacquard_common::BosStr> core::fmt::Display 332 + for LabelValueDefinitionDefaultSetting<S> { 333 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 334 + write!(f, "{}", self.as_str()) 335 + } 336 + } 337 + 338 + impl<S: jacquard_common::BosStr> AsRef<str> for LabelValueDefinitionDefaultSetting<S> { 339 + fn as_ref(&self) -> &str { 340 + self.as_str() 341 + } 342 + } 343 + 344 + impl<S: jacquard_common::BosStr> serde::Serialize 345 + for LabelValueDefinitionDefaultSetting<S> { 346 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 347 + where 348 + Ser: serde::Serializer, 349 + { 350 + serializer.serialize_str(self.as_str()) 351 + } 352 + } 353 + 354 + impl<'de, S: serde::Deserialize<'de> + jacquard_common::BosStr> serde::Deserialize<'de> 355 + for LabelValueDefinitionDefaultSetting<S> { 356 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 357 + where 358 + D: serde::Deserializer<'de>, 359 + { 360 + let s = S::deserialize(deserializer)?; 361 + Ok(Self::from_value(s)) 362 + } 363 + } 364 + 365 + impl<S: jacquard_common::BosStr + Default> Default 366 + for LabelValueDefinitionDefaultSetting<S> { 367 + fn default() -> Self { 368 + Self::Other(Default::default()) 369 + } 370 + } 371 + 372 + impl<S: jacquard_common::BosStr> jacquard_common::IntoStatic 373 + for LabelValueDefinitionDefaultSetting<S> 374 + where 375 + S: jacquard_common::BosStr + jacquard_common::IntoStatic, 376 + S::Output: jacquard_common::BosStr, 377 + { 378 + type Output = LabelValueDefinitionDefaultSetting<S::Output>; 379 + fn into_static(self) -> Self::Output { 380 + match self { 381 + LabelValueDefinitionDefaultSetting::Ignore => { 382 + LabelValueDefinitionDefaultSetting::Ignore 383 + } 384 + LabelValueDefinitionDefaultSetting::Warn => { 385 + LabelValueDefinitionDefaultSetting::Warn 386 + } 387 + LabelValueDefinitionDefaultSetting::Hide => { 388 + LabelValueDefinitionDefaultSetting::Hide 389 + } 390 + LabelValueDefinitionDefaultSetting::Other(v) => { 391 + LabelValueDefinitionDefaultSetting::Other(v.into_static()) 392 + } 393 + } 394 + } 395 + } 396 + 397 + /// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. 398 + 399 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 400 + pub enum LabelValueDefinitionSeverity< 401 + S: jacquard_common::BosStr = jacquard_common::DefaultStr, 402 + > { 403 + Inform, 404 + Alert, 405 + None, 406 + Other(S), 407 + } 408 + 409 + impl<S: jacquard_common::BosStr> LabelValueDefinitionSeverity<S> { 410 + pub fn as_str(&self) -> &str { 411 + match self { 412 + Self::Inform => "inform", 413 + Self::Alert => "alert", 414 + Self::None => "none", 415 + Self::Other(s) => s.as_ref(), 416 + } 417 + } 418 + /// Construct from a string-like value, matching known values. 419 + pub fn from_value(s: S) -> Self { 420 + match s.as_ref() { 421 + "inform" => Self::Inform, 422 + "alert" => Self::Alert, 423 + "none" => Self::None, 424 + _ => Self::Other(s), 425 + } 426 + } 427 + } 428 + 429 + impl<S: jacquard_common::BosStr> core::fmt::Display for LabelValueDefinitionSeverity<S> { 430 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 431 + write!(f, "{}", self.as_str()) 432 + } 433 + } 434 + 435 + impl<S: jacquard_common::BosStr> AsRef<str> for LabelValueDefinitionSeverity<S> { 436 + fn as_ref(&self) -> &str { 437 + self.as_str() 438 + } 439 + } 440 + 441 + impl<S: jacquard_common::BosStr> serde::Serialize for LabelValueDefinitionSeverity<S> { 442 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 443 + where 444 + Ser: serde::Serializer, 445 + { 446 + serializer.serialize_str(self.as_str()) 447 + } 448 + } 449 + 450 + impl<'de, S: serde::Deserialize<'de> + jacquard_common::BosStr> serde::Deserialize<'de> 451 + for LabelValueDefinitionSeverity<S> { 452 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 453 + where 454 + D: serde::Deserializer<'de>, 455 + { 456 + let s = S::deserialize(deserializer)?; 457 + Ok(Self::from_value(s)) 458 + } 459 + } 460 + 461 + impl<S: jacquard_common::BosStr + Default> Default for LabelValueDefinitionSeverity<S> { 462 + fn default() -> Self { 463 + Self::Other(Default::default()) 464 + } 465 + } 466 + 467 + impl<S: jacquard_common::BosStr> jacquard_common::IntoStatic 468 + for LabelValueDefinitionSeverity<S> 469 + where 470 + S: jacquard_common::BosStr + jacquard_common::IntoStatic, 471 + S::Output: jacquard_common::BosStr, 472 + { 473 + type Output = LabelValueDefinitionSeverity<S::Output>; 474 + fn into_static(self) -> Self::Output { 475 + match self { 476 + LabelValueDefinitionSeverity::Inform => LabelValueDefinitionSeverity::Inform, 477 + LabelValueDefinitionSeverity::Alert => LabelValueDefinitionSeverity::Alert, 478 + LabelValueDefinitionSeverity::None => LabelValueDefinitionSeverity::None, 479 + LabelValueDefinitionSeverity::Other(v) => { 480 + LabelValueDefinitionSeverity::Other(v.into_static()) 481 + } 482 + } 483 + } 484 + } 485 + 486 + /// Strings which describe the label in the UI, localized into a specific language. 487 + 488 + #[derive( 489 + serde::Serialize, 490 + serde::Deserialize, 491 + Debug, 492 + Clone, 493 + PartialEq, 494 + Eq, 495 + jacquard_derive::IntoStatic 496 + )] 497 + 498 + #[serde( 499 + rename_all = "camelCase", 500 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 501 + )] 502 + pub struct LabelValueDefinitionStrings< 503 + S: jacquard_common::BosStr = jacquard_common::DefaultStr, 504 + > { 505 + ///A longer description of what the label means and why it might be applied. 506 + pub description: S, 507 + ///The code of the language these strings are written in. 508 + pub lang: jacquard_common::types::string::Language, 509 + ///A short human-readable name for the label. 510 + pub name: S, 511 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 512 + pub extra_data: core::option::Option< 513 + alloc::collections::BTreeMap< 514 + jacquard_common::deps::smol_str::SmolStr, 515 + jacquard_common::types::value::Data<S>, 516 + >, 517 + >, 518 + } 519 + 520 + /// Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel. 521 + 522 + #[derive( 523 + serde::Serialize, 524 + serde::Deserialize, 525 + Debug, 526 + Clone, 527 + PartialEq, 528 + Eq, 529 + jacquard_derive::IntoStatic, 530 + Default 531 + )] 532 + 533 + #[serde( 534 + rename_all = "camelCase", 535 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 536 + )] 537 + pub struct SelfLabel<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 538 + ///The short string name of the value or type of this label. 539 + pub val: S, 540 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 541 + pub extra_data: core::option::Option< 542 + alloc::collections::BTreeMap< 543 + jacquard_common::deps::smol_str::SmolStr, 544 + jacquard_common::types::value::Data<S>, 545 + >, 546 + >, 547 + } 548 + 549 + /// Metadata tags on an atproto record, published by the author within the record. 550 + 551 + #[derive( 552 + serde::Serialize, 553 + serde::Deserialize, 554 + Debug, 555 + Clone, 556 + PartialEq, 557 + Eq, 558 + jacquard_derive::IntoStatic 559 + )] 560 + 561 + #[serde( 562 + rename_all = "camelCase", 563 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 564 + )] 565 + pub struct SelfLabels<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 566 + pub values: Vec<crate::macro_mode::com_atproto::label::SelfLabel<S>>, 567 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 568 + pub extra_data: core::option::Option< 569 + alloc::collections::BTreeMap< 570 + jacquard_common::deps::smol_str::SmolStr, 571 + jacquard_common::types::value::Data<S>, 572 + >, 573 + >, 574 + } 575 + 576 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Label<S> { 577 + fn nsid() -> &'static str { 578 + "com.atproto.label.defs" 579 + } 580 + fn def_name() -> &'static str { 581 + "label" 582 + } 583 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 584 + lexicon_doc_com_atproto_label_defs() 585 + } 586 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 587 + { 588 + let value = &self.val; 589 + #[allow(unused_comparisons)] 590 + if <str>::len(value.as_ref()) > 128usize { 591 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 592 + path: jacquard_lexicon::validation::ValidationPath::from_field( 593 + "val", 594 + ), 595 + max: 128usize, 596 + actual: <str>::len(value.as_ref()), 597 + }); 598 + } 599 + } 600 + Ok(()) 601 + } 602 + } 603 + 604 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 605 + for LabelValueDefinition<S> { 606 + fn nsid() -> &'static str { 607 + "com.atproto.label.defs" 608 + } 609 + fn def_name() -> &'static str { 610 + "labelValueDefinition" 611 + } 612 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 613 + lexicon_doc_com_atproto_label_defs() 614 + } 615 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 616 + { 617 + let value = &self.identifier; 618 + #[allow(unused_comparisons)] 619 + if <str>::len(value.as_ref()) > 100usize { 620 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 621 + path: jacquard_lexicon::validation::ValidationPath::from_field( 622 + "identifier", 623 + ), 624 + max: 100usize, 625 + actual: <str>::len(value.as_ref()), 626 + }); 627 + } 628 + } 629 + { 630 + let value = &self.identifier; 631 + { 632 + let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes( 633 + value.as_ref(), 634 + true, 635 + ) 636 + .count(); 637 + if count > 100usize { 638 + return Err(jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 639 + path: jacquard_lexicon::validation::ValidationPath::from_field( 640 + "identifier", 641 + ), 642 + max: 100usize, 643 + actual: count, 644 + }); 645 + } 646 + } 647 + } 648 + Ok(()) 649 + } 650 + } 651 + 652 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 653 + for LabelValueDefinitionStrings<S> { 654 + fn nsid() -> &'static str { 655 + "com.atproto.label.defs" 656 + } 657 + fn def_name() -> &'static str { 658 + "labelValueDefinitionStrings" 659 + } 660 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 661 + lexicon_doc_com_atproto_label_defs() 662 + } 663 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 664 + { 665 + let value = &self.description; 666 + #[allow(unused_comparisons)] 667 + if <str>::len(value.as_ref()) > 100000usize { 668 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 669 + path: jacquard_lexicon::validation::ValidationPath::from_field( 670 + "description", 671 + ), 672 + max: 100000usize, 673 + actual: <str>::len(value.as_ref()), 674 + }); 675 + } 676 + } 677 + { 678 + let value = &self.description; 679 + { 680 + let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes( 681 + value.as_ref(), 682 + true, 683 + ) 684 + .count(); 685 + if count > 10000usize { 686 + return Err(jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 687 + path: jacquard_lexicon::validation::ValidationPath::from_field( 688 + "description", 689 + ), 690 + max: 10000usize, 691 + actual: count, 692 + }); 693 + } 694 + } 695 + } 696 + { 697 + let value = &self.name; 698 + #[allow(unused_comparisons)] 699 + if <str>::len(value.as_ref()) > 640usize { 700 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 701 + path: jacquard_lexicon::validation::ValidationPath::from_field( 702 + "name", 703 + ), 704 + max: 640usize, 705 + actual: <str>::len(value.as_ref()), 706 + }); 707 + } 708 + } 709 + { 710 + let value = &self.name; 711 + { 712 + let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes( 713 + value.as_ref(), 714 + true, 715 + ) 716 + .count(); 717 + if count > 64usize { 718 + return Err(jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 719 + path: jacquard_lexicon::validation::ValidationPath::from_field( 720 + "name", 721 + ), 722 + max: 64usize, 723 + actual: count, 724 + }); 725 + } 726 + } 727 + } 728 + Ok(()) 729 + } 730 + } 731 + 732 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 733 + for SelfLabel<S> { 734 + fn nsid() -> &'static str { 735 + "com.atproto.label.defs" 736 + } 737 + fn def_name() -> &'static str { 738 + "selfLabel" 739 + } 740 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 741 + lexicon_doc_com_atproto_label_defs() 742 + } 743 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 744 + { 745 + let value = &self.val; 746 + #[allow(unused_comparisons)] 747 + if <str>::len(value.as_ref()) > 128usize { 748 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 749 + path: jacquard_lexicon::validation::ValidationPath::from_field( 750 + "val", 751 + ), 752 + max: 128usize, 753 + actual: <str>::len(value.as_ref()), 754 + }); 755 + } 756 + } 757 + Ok(()) 758 + } 759 + } 760 + 761 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 762 + for SelfLabels<S> { 763 + fn nsid() -> &'static str { 764 + "com.atproto.label.defs" 765 + } 766 + fn def_name() -> &'static str { 767 + "selfLabels" 768 + } 769 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 770 + lexicon_doc_com_atproto_label_defs() 771 + } 772 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 773 + { 774 + let value = &self.values; 775 + #[allow(unused_comparisons)] 776 + if value.len() > 10usize { 777 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 778 + path: jacquard_lexicon::validation::ValidationPath::from_field( 779 + "values", 780 + ), 781 + max: 10usize, 782 + actual: value.len(), 783 + }); 784 + } 785 + } 786 + Ok(()) 787 + } 788 + } 789 + 790 + pub mod label_state { 791 + 792 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 793 + #[allow(unused)] 794 + use ::core::marker::PhantomData; 795 + mod sealed { 796 + pub trait Sealed {} 797 + } 798 + /// State trait tracking which required fields have been set 799 + pub trait State: sealed::Sealed { 800 + type Cts; 801 + type Uri; 802 + type Src; 803 + type Val; 804 + } 805 + /// Empty state - all required fields are unset 806 + pub struct Empty(()); 807 + impl sealed::Sealed for Empty {} 808 + impl State for Empty { 809 + type Cts = Unset; 810 + type Uri = Unset; 811 + type Src = Unset; 812 + type Val = Unset; 813 + } 814 + ///State transition - sets the `cts` field to Set 815 + pub struct SetCts<St: State = Empty>(PhantomData<fn() -> St>); 816 + impl<St: State> sealed::Sealed for SetCts<St> {} 817 + impl<St: State> State for SetCts<St> { 818 + type Cts = Set<members::cts>; 819 + type Uri = St::Uri; 820 + type Src = St::Src; 821 + type Val = St::Val; 822 + } 823 + ///State transition - sets the `uri` field to Set 824 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 825 + impl<St: State> sealed::Sealed for SetUri<St> {} 826 + impl<St: State> State for SetUri<St> { 827 + type Cts = St::Cts; 828 + type Uri = Set<members::uri>; 829 + type Src = St::Src; 830 + type Val = St::Val; 831 + } 832 + ///State transition - sets the `src` field to Set 833 + pub struct SetSrc<St: State = Empty>(PhantomData<fn() -> St>); 834 + impl<St: State> sealed::Sealed for SetSrc<St> {} 835 + impl<St: State> State for SetSrc<St> { 836 + type Cts = St::Cts; 837 + type Uri = St::Uri; 838 + type Src = Set<members::src>; 839 + type Val = St::Val; 840 + } 841 + ///State transition - sets the `val` field to Set 842 + pub struct SetVal<St: State = Empty>(PhantomData<fn() -> St>); 843 + impl<St: State> sealed::Sealed for SetVal<St> {} 844 + impl<St: State> State for SetVal<St> { 845 + type Cts = St::Cts; 846 + type Uri = St::Uri; 847 + type Src = St::Src; 848 + type Val = Set<members::val>; 849 + } 850 + /// Marker types for field names 851 + #[allow(non_camel_case_types)] 852 + pub mod members { 853 + ///Marker type for the `cts` field 854 + pub struct cts(()); 855 + ///Marker type for the `uri` field 856 + pub struct uri(()); 857 + ///Marker type for the `src` field 858 + pub struct src(()); 859 + ///Marker type for the `val` field 860 + pub struct val(()); 861 + } 862 + } 863 + 864 + /// Builder for constructing an instance of this type. 865 + pub struct LabelBuilder<S: jacquard_common::BosStr, St: label_state::State> { 866 + _state: ::core::marker::PhantomData<fn() -> St>, 867 + _fields: ( 868 + core::option::Option<jacquard_common::types::string::Cid<S>>, 869 + core::option::Option<jacquard_common::types::string::Datetime>, 870 + core::option::Option<jacquard_common::types::string::Datetime>, 871 + core::option::Option<bool>, 872 + core::option::Option<jacquard_common::deps::bytes::Bytes>, 873 + core::option::Option<jacquard_common::types::string::Did<S>>, 874 + core::option::Option<jacquard_common::types::string::UriValue<S>>, 875 + core::option::Option<S>, 876 + core::option::Option<i64>, 877 + ), 878 + _type: ::core::marker::PhantomData<fn() -> S>, 879 + } 880 + 881 + impl<S: jacquard_common::BosStr> Label<S> { 882 + /// Create a new builder for this type. 883 + pub fn new() -> LabelBuilder<S, label_state::Empty> { 884 + LabelBuilder::new() 885 + } 886 + } 887 + 888 + impl<S: jacquard_common::BosStr> LabelBuilder<S, label_state::Empty> { 889 + /// Create a new builder with all fields unset. 890 + pub fn new() -> Self { 891 + LabelBuilder { 892 + _state: ::core::marker::PhantomData, 893 + _fields: (None, None, None, None, None, None, None, None, None), 894 + _type: ::core::marker::PhantomData, 895 + } 896 + } 897 + } 898 + 899 + impl<S: jacquard_common::BosStr, St: label_state::State> LabelBuilder<S, St> { 900 + /// Set the `cid` field (optional) 901 + pub fn cid( 902 + mut self, 903 + value: impl Into<Option<jacquard_common::types::string::Cid<S>>>, 904 + ) -> Self { 905 + self._fields.0 = value.into(); 906 + self 907 + } 908 + /// Set the `cid` field to an Option value (optional) 909 + pub fn maybe_cid( 910 + mut self, 911 + value: Option<jacquard_common::types::string::Cid<S>>, 912 + ) -> Self { 913 + self._fields.0 = value; 914 + self 915 + } 916 + } 917 + 918 + impl<S: jacquard_common::BosStr, St> LabelBuilder<S, St> 919 + where 920 + St: label_state::State, 921 + St::Cts: label_state::IsUnset, 922 + { 923 + /// Set the `cts` field (required) 924 + pub fn cts( 925 + mut self, 926 + value: impl Into<jacquard_common::types::string::Datetime>, 927 + ) -> LabelBuilder<S, label_state::SetCts<St>> { 928 + self._fields.1 = ::core::option::Option::Some(value.into()); 929 + LabelBuilder { 930 + _state: ::core::marker::PhantomData, 931 + _fields: self._fields, 932 + _type: ::core::marker::PhantomData, 933 + } 934 + } 935 + } 936 + 937 + impl<S: jacquard_common::BosStr, St: label_state::State> LabelBuilder<S, St> { 938 + /// Set the `exp` field (optional) 939 + pub fn exp( 940 + mut self, 941 + value: impl Into<Option<jacquard_common::types::string::Datetime>>, 942 + ) -> Self { 943 + self._fields.2 = value.into(); 944 + self 945 + } 946 + /// Set the `exp` field to an Option value (optional) 947 + pub fn maybe_exp( 948 + mut self, 949 + value: Option<jacquard_common::types::string::Datetime>, 950 + ) -> Self { 951 + self._fields.2 = value; 952 + self 953 + } 954 + } 955 + 956 + impl<S: jacquard_common::BosStr, St: label_state::State> LabelBuilder<S, St> { 957 + /// Set the `neg` field (optional) 958 + pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self { 959 + self._fields.3 = value.into(); 960 + self 961 + } 962 + /// Set the `neg` field to an Option value (optional) 963 + pub fn maybe_neg(mut self, value: Option<bool>) -> Self { 964 + self._fields.3 = value; 965 + self 966 + } 967 + } 968 + 969 + impl<S: jacquard_common::BosStr, St: label_state::State> LabelBuilder<S, St> { 970 + /// Set the `sig` field (optional) 971 + pub fn sig( 972 + mut self, 973 + value: impl Into<Option<jacquard_common::deps::bytes::Bytes>>, 974 + ) -> Self { 975 + self._fields.4 = value.into(); 976 + self 977 + } 978 + /// Set the `sig` field to an Option value (optional) 979 + pub fn maybe_sig( 980 + mut self, 981 + value: Option<jacquard_common::deps::bytes::Bytes>, 982 + ) -> Self { 983 + self._fields.4 = value; 984 + self 985 + } 986 + } 987 + 988 + impl<S: jacquard_common::BosStr, St> LabelBuilder<S, St> 989 + where 990 + St: label_state::State, 991 + St::Src: label_state::IsUnset, 992 + { 993 + /// Set the `src` field (required) 994 + pub fn src( 995 + mut self, 996 + value: impl Into<jacquard_common::types::string::Did<S>>, 997 + ) -> LabelBuilder<S, label_state::SetSrc<St>> { 998 + self._fields.5 = ::core::option::Option::Some(value.into()); 999 + LabelBuilder { 1000 + _state: ::core::marker::PhantomData, 1001 + _fields: self._fields, 1002 + _type: ::core::marker::PhantomData, 1003 + } 1004 + } 1005 + } 1006 + 1007 + impl<S: jacquard_common::BosStr, St> LabelBuilder<S, St> 1008 + where 1009 + St: label_state::State, 1010 + St::Uri: label_state::IsUnset, 1011 + { 1012 + /// Set the `uri` field (required) 1013 + pub fn uri( 1014 + mut self, 1015 + value: impl Into<jacquard_common::types::string::UriValue<S>>, 1016 + ) -> LabelBuilder<S, label_state::SetUri<St>> { 1017 + self._fields.6 = ::core::option::Option::Some(value.into()); 1018 + LabelBuilder { 1019 + _state: ::core::marker::PhantomData, 1020 + _fields: self._fields, 1021 + _type: ::core::marker::PhantomData, 1022 + } 1023 + } 1024 + } 1025 + 1026 + impl<S: jacquard_common::BosStr, St> LabelBuilder<S, St> 1027 + where 1028 + St: label_state::State, 1029 + St::Val: label_state::IsUnset, 1030 + { 1031 + /// Set the `val` field (required) 1032 + pub fn val( 1033 + mut self, 1034 + value: impl Into<S>, 1035 + ) -> LabelBuilder<S, label_state::SetVal<St>> { 1036 + self._fields.7 = ::core::option::Option::Some(value.into()); 1037 + LabelBuilder { 1038 + _state: ::core::marker::PhantomData, 1039 + _fields: self._fields, 1040 + _type: ::core::marker::PhantomData, 1041 + } 1042 + } 1043 + } 1044 + 1045 + impl<S: jacquard_common::BosStr, St: label_state::State> LabelBuilder<S, St> { 1046 + /// Set the `ver` field (optional) 1047 + pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self { 1048 + self._fields.8 = value.into(); 1049 + self 1050 + } 1051 + /// Set the `ver` field to an Option value (optional) 1052 + pub fn maybe_ver(mut self, value: Option<i64>) -> Self { 1053 + self._fields.8 = value; 1054 + self 1055 + } 1056 + } 1057 + 1058 + impl<S: jacquard_common::BosStr, St> LabelBuilder<S, St> 1059 + where 1060 + St: label_state::State, 1061 + St::Cts: label_state::IsSet, 1062 + St::Uri: label_state::IsSet, 1063 + St::Src: label_state::IsSet, 1064 + St::Val: label_state::IsSet, 1065 + { 1066 + /// Build the final struct. 1067 + pub fn build(self) -> Label<S> { 1068 + Label { 1069 + cid: self._fields.0, 1070 + cts: self._fields.1.unwrap(), 1071 + exp: self._fields.2, 1072 + neg: self._fields.3, 1073 + sig: self._fields.4, 1074 + src: self._fields.5.unwrap(), 1075 + uri: self._fields.6.unwrap(), 1076 + val: self._fields.7.unwrap(), 1077 + ver: self._fields.8, 1078 + extra_data: Default::default(), 1079 + } 1080 + } 1081 + /// Build the final struct with custom extra_data. 1082 + pub fn build_with_data( 1083 + self, 1084 + extra_data: alloc::collections::BTreeMap< 1085 + jacquard_common::deps::smol_str::SmolStr, 1086 + jacquard_common::types::value::Data<S>, 1087 + >, 1088 + ) -> Label<S> { 1089 + Label { 1090 + cid: self._fields.0, 1091 + cts: self._fields.1.unwrap(), 1092 + exp: self._fields.2, 1093 + neg: self._fields.3, 1094 + sig: self._fields.4, 1095 + src: self._fields.5.unwrap(), 1096 + uri: self._fields.6.unwrap(), 1097 + val: self._fields.7.unwrap(), 1098 + ver: self._fields.8, 1099 + extra_data: Some(extra_data), 1100 + } 1101 + } 1102 + } 1103 + 1104 + fn lexicon_doc_com_atproto_label_defs() -> jacquard_lexicon::lexicon::LexiconDoc< 1105 + 'static, 1106 + > { 1107 + ::jacquard_lexicon::lexicon::LexiconDoc { 1108 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 1109 + id: ::jacquard_common::CowStr::new_static("com.atproto.label.defs"), 1110 + defs: { 1111 + let mut map = ::alloc::collections::BTreeMap::new(); 1112 + map.insert( 1113 + ::jacquard_common::deps::smol_str::SmolStr::new_static("label"), 1114 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 1115 + description: Some( 1116 + ::jacquard_common::CowStr::new_static( 1117 + "Metadata tag on an atproto resource (eg, repo or record).", 1118 + ), 1119 + ), 1120 + required: Some( 1121 + vec![ 1122 + ::jacquard_common::deps::smol_str::SmolStr::new_static("src"), 1123 + ::jacquard_common::deps::smol_str::SmolStr::new_static("uri"), 1124 + ::jacquard_common::deps::smol_str::SmolStr::new_static("val"), 1125 + ::jacquard_common::deps::smol_str::SmolStr::new_static("cts") 1126 + ], 1127 + ), 1128 + properties: { 1129 + #[allow(unused_mut)] 1130 + let mut map = ::alloc::collections::BTreeMap::new(); 1131 + map.insert( 1132 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1133 + "cid", 1134 + ), 1135 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1136 + description: Some( 1137 + ::jacquard_common::CowStr::new_static( 1138 + "Optionally, CID specifying the specific version of 'uri' resource this label applies to.", 1139 + ), 1140 + ), 1141 + format: Some( 1142 + ::jacquard_lexicon::lexicon::LexStringFormat::Cid, 1143 + ), 1144 + ..Default::default() 1145 + }), 1146 + ); 1147 + map.insert( 1148 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1149 + "cts", 1150 + ), 1151 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1152 + description: Some( 1153 + ::jacquard_common::CowStr::new_static( 1154 + "Timestamp when this label was created.", 1155 + ), 1156 + ), 1157 + format: Some( 1158 + ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 1159 + ), 1160 + ..Default::default() 1161 + }), 1162 + ); 1163 + map.insert( 1164 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1165 + "exp", 1166 + ), 1167 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1168 + description: Some( 1169 + ::jacquard_common::CowStr::new_static( 1170 + "Timestamp at which this label expires (no longer applies).", 1171 + ), 1172 + ), 1173 + format: Some( 1174 + ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 1175 + ), 1176 + ..Default::default() 1177 + }), 1178 + ); 1179 + map.insert( 1180 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1181 + "neg", 1182 + ), 1183 + ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 1184 + ..Default::default() 1185 + }), 1186 + ); 1187 + map.insert( 1188 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1189 + "sig", 1190 + ), 1191 + ::jacquard_lexicon::lexicon::LexObjectProperty::Bytes(::jacquard_lexicon::lexicon::LexBytes { 1192 + ..Default::default() 1193 + }), 1194 + ); 1195 + map.insert( 1196 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1197 + "src", 1198 + ), 1199 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1200 + description: Some( 1201 + ::jacquard_common::CowStr::new_static( 1202 + "DID of the actor who created this label.", 1203 + ), 1204 + ), 1205 + format: Some( 1206 + ::jacquard_lexicon::lexicon::LexStringFormat::Did, 1207 + ), 1208 + ..Default::default() 1209 + }), 1210 + ); 1211 + map.insert( 1212 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1213 + "uri", 1214 + ), 1215 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1216 + description: Some( 1217 + ::jacquard_common::CowStr::new_static( 1218 + "AT URI of the record, repository (account), or other resource that this label applies to.", 1219 + ), 1220 + ), 1221 + format: Some( 1222 + ::jacquard_lexicon::lexicon::LexStringFormat::Uri, 1223 + ), 1224 + ..Default::default() 1225 + }), 1226 + ); 1227 + map.insert( 1228 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1229 + "val", 1230 + ), 1231 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1232 + description: Some( 1233 + ::jacquard_common::CowStr::new_static( 1234 + "The short string name of the value or type of this label.", 1235 + ), 1236 + ), 1237 + max_length: Some(128usize), 1238 + ..Default::default() 1239 + }), 1240 + ); 1241 + map.insert( 1242 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1243 + "ver", 1244 + ), 1245 + ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 1246 + ..Default::default() 1247 + }), 1248 + ); 1249 + map 1250 + }, 1251 + ..Default::default() 1252 + }), 1253 + ); 1254 + map.insert( 1255 + ::jacquard_common::deps::smol_str::SmolStr::new_static("labelValue"), 1256 + ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { 1257 + ..Default::default() 1258 + }), 1259 + ); 1260 + map.insert( 1261 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1262 + "labelValueDefinition", 1263 + ), 1264 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 1265 + description: Some( 1266 + ::jacquard_common::CowStr::new_static( 1267 + "Declares a label value and its expected interpretations and behaviors.", 1268 + ), 1269 + ), 1270 + required: Some( 1271 + vec![ 1272 + ::jacquard_common::deps::smol_str::SmolStr::new_static("identifier"), 1273 + ::jacquard_common::deps::smol_str::SmolStr::new_static("severity"), 1274 + ::jacquard_common::deps::smol_str::SmolStr::new_static("blurs"), 1275 + ::jacquard_common::deps::smol_str::SmolStr::new_static("locales") 1276 + ], 1277 + ), 1278 + properties: { 1279 + #[allow(unused_mut)] 1280 + let mut map = ::alloc::collections::BTreeMap::new(); 1281 + map.insert( 1282 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1283 + "adultOnly", 1284 + ), 1285 + ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 1286 + ..Default::default() 1287 + }), 1288 + ); 1289 + map.insert( 1290 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1291 + "blurs", 1292 + ), 1293 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1294 + description: Some( 1295 + ::jacquard_common::CowStr::new_static( 1296 + "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.", 1297 + ), 1298 + ), 1299 + ..Default::default() 1300 + }), 1301 + ); 1302 + map.insert( 1303 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1304 + "defaultSetting", 1305 + ), 1306 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1307 + description: Some( 1308 + ::jacquard_common::CowStr::new_static( 1309 + "The default setting for this label.", 1310 + ), 1311 + ), 1312 + ..Default::default() 1313 + }), 1314 + ); 1315 + map.insert( 1316 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1317 + "identifier", 1318 + ), 1319 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1320 + description: Some( 1321 + ::jacquard_common::CowStr::new_static( 1322 + "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).", 1323 + ), 1324 + ), 1325 + max_length: Some(100usize), 1326 + max_graphemes: Some(100usize), 1327 + ..Default::default() 1328 + }), 1329 + ); 1330 + map.insert( 1331 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1332 + "locales", 1333 + ), 1334 + ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 1335 + items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 1336 + r#ref: ::jacquard_common::CowStr::new_static( 1337 + "#labelValueDefinitionStrings", 1338 + ), 1339 + ..Default::default() 1340 + }), 1341 + ..Default::default() 1342 + }), 1343 + ); 1344 + map.insert( 1345 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1346 + "severity", 1347 + ), 1348 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1349 + description: Some( 1350 + ::jacquard_common::CowStr::new_static( 1351 + "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.", 1352 + ), 1353 + ), 1354 + ..Default::default() 1355 + }), 1356 + ); 1357 + map 1358 + }, 1359 + ..Default::default() 1360 + }), 1361 + ); 1362 + map.insert( 1363 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1364 + "labelValueDefinitionStrings", 1365 + ), 1366 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 1367 + description: Some( 1368 + ::jacquard_common::CowStr::new_static( 1369 + "Strings which describe the label in the UI, localized into a specific language.", 1370 + ), 1371 + ), 1372 + required: Some( 1373 + vec![ 1374 + ::jacquard_common::deps::smol_str::SmolStr::new_static("lang"), 1375 + ::jacquard_common::deps::smol_str::SmolStr::new_static("name"), 1376 + ::jacquard_common::deps::smol_str::SmolStr::new_static("description") 1377 + ], 1378 + ), 1379 + properties: { 1380 + #[allow(unused_mut)] 1381 + let mut map = ::alloc::collections::BTreeMap::new(); 1382 + map.insert( 1383 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1384 + "description", 1385 + ), 1386 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1387 + description: Some( 1388 + ::jacquard_common::CowStr::new_static( 1389 + "A longer description of what the label means and why it might be applied.", 1390 + ), 1391 + ), 1392 + max_length: Some(100000usize), 1393 + max_graphemes: Some(10000usize), 1394 + ..Default::default() 1395 + }), 1396 + ); 1397 + map.insert( 1398 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1399 + "lang", 1400 + ), 1401 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1402 + description: Some( 1403 + ::jacquard_common::CowStr::new_static( 1404 + "The code of the language these strings are written in.", 1405 + ), 1406 + ), 1407 + format: Some( 1408 + ::jacquard_lexicon::lexicon::LexStringFormat::Language, 1409 + ), 1410 + ..Default::default() 1411 + }), 1412 + ); 1413 + map.insert( 1414 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1415 + "name", 1416 + ), 1417 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1418 + description: Some( 1419 + ::jacquard_common::CowStr::new_static( 1420 + "A short human-readable name for the label.", 1421 + ), 1422 + ), 1423 + max_length: Some(640usize), 1424 + max_graphemes: Some(64usize), 1425 + ..Default::default() 1426 + }), 1427 + ); 1428 + map 1429 + }, 1430 + ..Default::default() 1431 + }), 1432 + ); 1433 + map.insert( 1434 + ::jacquard_common::deps::smol_str::SmolStr::new_static("selfLabel"), 1435 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 1436 + description: Some( 1437 + ::jacquard_common::CowStr::new_static( 1438 + "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.", 1439 + ), 1440 + ), 1441 + required: Some( 1442 + vec![ 1443 + ::jacquard_common::deps::smol_str::SmolStr::new_static("val") 1444 + ], 1445 + ), 1446 + properties: { 1447 + #[allow(unused_mut)] 1448 + let mut map = ::alloc::collections::BTreeMap::new(); 1449 + map.insert( 1450 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1451 + "val", 1452 + ), 1453 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1454 + description: Some( 1455 + ::jacquard_common::CowStr::new_static( 1456 + "The short string name of the value or type of this label.", 1457 + ), 1458 + ), 1459 + max_length: Some(128usize), 1460 + ..Default::default() 1461 + }), 1462 + ); 1463 + map 1464 + }, 1465 + ..Default::default() 1466 + }), 1467 + ); 1468 + map.insert( 1469 + ::jacquard_common::deps::smol_str::SmolStr::new_static("selfLabels"), 1470 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 1471 + description: Some( 1472 + ::jacquard_common::CowStr::new_static( 1473 + "Metadata tags on an atproto record, published by the author within the record.", 1474 + ), 1475 + ), 1476 + required: Some( 1477 + vec![ 1478 + ::jacquard_common::deps::smol_str::SmolStr::new_static("values") 1479 + ], 1480 + ), 1481 + properties: { 1482 + #[allow(unused_mut)] 1483 + let mut map = ::alloc::collections::BTreeMap::new(); 1484 + map.insert( 1485 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 1486 + "values", 1487 + ), 1488 + ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 1489 + items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 1490 + r#ref: ::jacquard_common::CowStr::new_static("#selfLabel"), 1491 + ..Default::default() 1492 + }), 1493 + max_length: Some(10usize), 1494 + ..Default::default() 1495 + }), 1496 + ); 1497 + map 1498 + }, 1499 + ..Default::default() 1500 + }), 1501 + ); 1502 + map 1503 + }, 1504 + ..Default::default() 1505 + } 1506 + } 1507 + 1508 + pub mod label_value_definition_state { 1509 + 1510 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1511 + #[allow(unused)] 1512 + use ::core::marker::PhantomData; 1513 + mod sealed { 1514 + pub trait Sealed {} 1515 + } 1516 + /// State trait tracking which required fields have been set 1517 + pub trait State: sealed::Sealed { 1518 + type Locales; 1519 + type Severity; 1520 + type Blurs; 1521 + type Identifier; 1522 + } 1523 + /// Empty state - all required fields are unset 1524 + pub struct Empty(()); 1525 + impl sealed::Sealed for Empty {} 1526 + impl State for Empty { 1527 + type Locales = Unset; 1528 + type Severity = Unset; 1529 + type Blurs = Unset; 1530 + type Identifier = Unset; 1531 + } 1532 + ///State transition - sets the `locales` field to Set 1533 + pub struct SetLocales<St: State = Empty>(PhantomData<fn() -> St>); 1534 + impl<St: State> sealed::Sealed for SetLocales<St> {} 1535 + impl<St: State> State for SetLocales<St> { 1536 + type Locales = Set<members::locales>; 1537 + type Severity = St::Severity; 1538 + type Blurs = St::Blurs; 1539 + type Identifier = St::Identifier; 1540 + } 1541 + ///State transition - sets the `severity` field to Set 1542 + pub struct SetSeverity<St: State = Empty>(PhantomData<fn() -> St>); 1543 + impl<St: State> sealed::Sealed for SetSeverity<St> {} 1544 + impl<St: State> State for SetSeverity<St> { 1545 + type Locales = St::Locales; 1546 + type Severity = Set<members::severity>; 1547 + type Blurs = St::Blurs; 1548 + type Identifier = St::Identifier; 1549 + } 1550 + ///State transition - sets the `blurs` field to Set 1551 + pub struct SetBlurs<St: State = Empty>(PhantomData<fn() -> St>); 1552 + impl<St: State> sealed::Sealed for SetBlurs<St> {} 1553 + impl<St: State> State for SetBlurs<St> { 1554 + type Locales = St::Locales; 1555 + type Severity = St::Severity; 1556 + type Blurs = Set<members::blurs>; 1557 + type Identifier = St::Identifier; 1558 + } 1559 + ///State transition - sets the `identifier` field to Set 1560 + pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>); 1561 + impl<St: State> sealed::Sealed for SetIdentifier<St> {} 1562 + impl<St: State> State for SetIdentifier<St> { 1563 + type Locales = St::Locales; 1564 + type Severity = St::Severity; 1565 + type Blurs = St::Blurs; 1566 + type Identifier = Set<members::identifier>; 1567 + } 1568 + /// Marker types for field names 1569 + #[allow(non_camel_case_types)] 1570 + pub mod members { 1571 + ///Marker type for the `locales` field 1572 + pub struct locales(()); 1573 + ///Marker type for the `severity` field 1574 + pub struct severity(()); 1575 + ///Marker type for the `blurs` field 1576 + pub struct blurs(()); 1577 + ///Marker type for the `identifier` field 1578 + pub struct identifier(()); 1579 + } 1580 + } 1581 + 1582 + /// Builder for constructing an instance of this type. 1583 + pub struct LabelValueDefinitionBuilder< 1584 + S: jacquard_common::BosStr, 1585 + St: label_value_definition_state::State, 1586 + > { 1587 + _state: ::core::marker::PhantomData<fn() -> St>, 1588 + _fields: ( 1589 + core::option::Option<bool>, 1590 + core::option::Option<LabelValueDefinitionBlurs<S>>, 1591 + core::option::Option<LabelValueDefinitionDefaultSetting<S>>, 1592 + core::option::Option<S>, 1593 + core::option::Option< 1594 + Vec<crate::macro_mode::com_atproto::label::LabelValueDefinitionStrings<S>>, 1595 + >, 1596 + core::option::Option<LabelValueDefinitionSeverity<S>>, 1597 + ), 1598 + _type: ::core::marker::PhantomData<fn() -> S>, 1599 + } 1600 + 1601 + impl<S: jacquard_common::BosStr> LabelValueDefinition<S> { 1602 + /// Create a new builder for this type. 1603 + pub fn new() -> LabelValueDefinitionBuilder<S, label_value_definition_state::Empty> { 1604 + LabelValueDefinitionBuilder::new() 1605 + } 1606 + } 1607 + 1608 + impl< 1609 + S: jacquard_common::BosStr, 1610 + > LabelValueDefinitionBuilder<S, label_value_definition_state::Empty> { 1611 + /// Create a new builder with all fields unset. 1612 + pub fn new() -> Self { 1613 + LabelValueDefinitionBuilder { 1614 + _state: ::core::marker::PhantomData, 1615 + _fields: (None, None, None, None, None, None), 1616 + _type: ::core::marker::PhantomData, 1617 + } 1618 + } 1619 + } 1620 + 1621 + impl< 1622 + S: jacquard_common::BosStr, 1623 + St: label_value_definition_state::State, 1624 + > LabelValueDefinitionBuilder<S, St> { 1625 + /// Set the `adultOnly` field (optional) 1626 + pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self { 1627 + self._fields.0 = value.into(); 1628 + self 1629 + } 1630 + /// Set the `adultOnly` field to an Option value (optional) 1631 + pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self { 1632 + self._fields.0 = value; 1633 + self 1634 + } 1635 + } 1636 + 1637 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionBuilder<S, St> 1638 + where 1639 + St: label_value_definition_state::State, 1640 + St::Blurs: label_value_definition_state::IsUnset, 1641 + { 1642 + /// Set the `blurs` field (required) 1643 + pub fn blurs( 1644 + mut self, 1645 + value: impl Into<LabelValueDefinitionBlurs<S>>, 1646 + ) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetBlurs<St>> { 1647 + self._fields.1 = ::core::option::Option::Some(value.into()); 1648 + LabelValueDefinitionBuilder { 1649 + _state: ::core::marker::PhantomData, 1650 + _fields: self._fields, 1651 + _type: ::core::marker::PhantomData, 1652 + } 1653 + } 1654 + } 1655 + 1656 + impl< 1657 + S: jacquard_common::BosStr, 1658 + St: label_value_definition_state::State, 1659 + > LabelValueDefinitionBuilder<S, St> { 1660 + /// Set the `defaultSetting` field (optional) 1661 + pub fn default_setting( 1662 + mut self, 1663 + value: impl Into<Option<LabelValueDefinitionDefaultSetting<S>>>, 1664 + ) -> Self { 1665 + self._fields.2 = value.into(); 1666 + self 1667 + } 1668 + /// Set the `defaultSetting` field to an Option value (optional) 1669 + pub fn maybe_default_setting( 1670 + mut self, 1671 + value: Option<LabelValueDefinitionDefaultSetting<S>>, 1672 + ) -> Self { 1673 + self._fields.2 = value; 1674 + self 1675 + } 1676 + } 1677 + 1678 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionBuilder<S, St> 1679 + where 1680 + St: label_value_definition_state::State, 1681 + St::Identifier: label_value_definition_state::IsUnset, 1682 + { 1683 + /// Set the `identifier` field (required) 1684 + pub fn identifier( 1685 + mut self, 1686 + value: impl Into<S>, 1687 + ) -> LabelValueDefinitionBuilder< 1688 + S, 1689 + label_value_definition_state::SetIdentifier<St>, 1690 + > { 1691 + self._fields.3 = ::core::option::Option::Some(value.into()); 1692 + LabelValueDefinitionBuilder { 1693 + _state: ::core::marker::PhantomData, 1694 + _fields: self._fields, 1695 + _type: ::core::marker::PhantomData, 1696 + } 1697 + } 1698 + } 1699 + 1700 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionBuilder<S, St> 1701 + where 1702 + St: label_value_definition_state::State, 1703 + St::Locales: label_value_definition_state::IsUnset, 1704 + { 1705 + /// Set the `locales` field (required) 1706 + pub fn locales( 1707 + mut self, 1708 + value: impl Into< 1709 + Vec<crate::macro_mode::com_atproto::label::LabelValueDefinitionStrings<S>>, 1710 + >, 1711 + ) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetLocales<St>> { 1712 + self._fields.4 = ::core::option::Option::Some(value.into()); 1713 + LabelValueDefinitionBuilder { 1714 + _state: ::core::marker::PhantomData, 1715 + _fields: self._fields, 1716 + _type: ::core::marker::PhantomData, 1717 + } 1718 + } 1719 + } 1720 + 1721 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionBuilder<S, St> 1722 + where 1723 + St: label_value_definition_state::State, 1724 + St::Severity: label_value_definition_state::IsUnset, 1725 + { 1726 + /// Set the `severity` field (required) 1727 + pub fn severity( 1728 + mut self, 1729 + value: impl Into<LabelValueDefinitionSeverity<S>>, 1730 + ) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetSeverity<St>> { 1731 + self._fields.5 = ::core::option::Option::Some(value.into()); 1732 + LabelValueDefinitionBuilder { 1733 + _state: ::core::marker::PhantomData, 1734 + _fields: self._fields, 1735 + _type: ::core::marker::PhantomData, 1736 + } 1737 + } 1738 + } 1739 + 1740 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionBuilder<S, St> 1741 + where 1742 + St: label_value_definition_state::State, 1743 + St::Locales: label_value_definition_state::IsSet, 1744 + St::Severity: label_value_definition_state::IsSet, 1745 + St::Blurs: label_value_definition_state::IsSet, 1746 + St::Identifier: label_value_definition_state::IsSet, 1747 + { 1748 + /// Build the final struct. 1749 + pub fn build(self) -> LabelValueDefinition<S> { 1750 + LabelValueDefinition { 1751 + adult_only: self._fields.0, 1752 + blurs: self._fields.1.unwrap(), 1753 + default_setting: self._fields.2, 1754 + identifier: self._fields.3.unwrap(), 1755 + locales: self._fields.4.unwrap(), 1756 + severity: self._fields.5.unwrap(), 1757 + extra_data: Default::default(), 1758 + } 1759 + } 1760 + /// Build the final struct with custom extra_data. 1761 + pub fn build_with_data( 1762 + self, 1763 + extra_data: alloc::collections::BTreeMap< 1764 + jacquard_common::deps::smol_str::SmolStr, 1765 + jacquard_common::types::value::Data<S>, 1766 + >, 1767 + ) -> LabelValueDefinition<S> { 1768 + LabelValueDefinition { 1769 + adult_only: self._fields.0, 1770 + blurs: self._fields.1.unwrap(), 1771 + default_setting: self._fields.2, 1772 + identifier: self._fields.3.unwrap(), 1773 + locales: self._fields.4.unwrap(), 1774 + severity: self._fields.5.unwrap(), 1775 + extra_data: Some(extra_data), 1776 + } 1777 + } 1778 + } 1779 + 1780 + pub mod label_value_definition_strings_state { 1781 + 1782 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1783 + #[allow(unused)] 1784 + use ::core::marker::PhantomData; 1785 + mod sealed { 1786 + pub trait Sealed {} 1787 + } 1788 + /// State trait tracking which required fields have been set 1789 + pub trait State: sealed::Sealed { 1790 + type Lang; 1791 + type Name; 1792 + type Description; 1793 + } 1794 + /// Empty state - all required fields are unset 1795 + pub struct Empty(()); 1796 + impl sealed::Sealed for Empty {} 1797 + impl State for Empty { 1798 + type Lang = Unset; 1799 + type Name = Unset; 1800 + type Description = Unset; 1801 + } 1802 + ///State transition - sets the `lang` field to Set 1803 + pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>); 1804 + impl<St: State> sealed::Sealed for SetLang<St> {} 1805 + impl<St: State> State for SetLang<St> { 1806 + type Lang = Set<members::lang>; 1807 + type Name = St::Name; 1808 + type Description = St::Description; 1809 + } 1810 + ///State transition - sets the `name` field to Set 1811 + pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>); 1812 + impl<St: State> sealed::Sealed for SetName<St> {} 1813 + impl<St: State> State for SetName<St> { 1814 + type Lang = St::Lang; 1815 + type Name = Set<members::name>; 1816 + type Description = St::Description; 1817 + } 1818 + ///State transition - sets the `description` field to Set 1819 + pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>); 1820 + impl<St: State> sealed::Sealed for SetDescription<St> {} 1821 + impl<St: State> State for SetDescription<St> { 1822 + type Lang = St::Lang; 1823 + type Name = St::Name; 1824 + type Description = Set<members::description>; 1825 + } 1826 + /// Marker types for field names 1827 + #[allow(non_camel_case_types)] 1828 + pub mod members { 1829 + ///Marker type for the `lang` field 1830 + pub struct lang(()); 1831 + ///Marker type for the `name` field 1832 + pub struct name(()); 1833 + ///Marker type for the `description` field 1834 + pub struct description(()); 1835 + } 1836 + } 1837 + 1838 + /// Builder for constructing an instance of this type. 1839 + pub struct LabelValueDefinitionStringsBuilder< 1840 + S: jacquard_common::BosStr, 1841 + St: label_value_definition_strings_state::State, 1842 + > { 1843 + _state: ::core::marker::PhantomData<fn() -> St>, 1844 + _fields: ( 1845 + core::option::Option<S>, 1846 + core::option::Option<jacquard_common::types::string::Language>, 1847 + core::option::Option<S>, 1848 + ), 1849 + _type: ::core::marker::PhantomData<fn() -> S>, 1850 + } 1851 + 1852 + impl<S: jacquard_common::BosStr> LabelValueDefinitionStrings<S> { 1853 + /// Create a new builder for this type. 1854 + pub fn new() -> LabelValueDefinitionStringsBuilder< 1855 + S, 1856 + label_value_definition_strings_state::Empty, 1857 + > { 1858 + LabelValueDefinitionStringsBuilder::new() 1859 + } 1860 + } 1861 + 1862 + impl< 1863 + S: jacquard_common::BosStr, 1864 + > LabelValueDefinitionStringsBuilder<S, label_value_definition_strings_state::Empty> { 1865 + /// Create a new builder with all fields unset. 1866 + pub fn new() -> Self { 1867 + LabelValueDefinitionStringsBuilder { 1868 + _state: ::core::marker::PhantomData, 1869 + _fields: (None, None, None), 1870 + _type: ::core::marker::PhantomData, 1871 + } 1872 + } 1873 + } 1874 + 1875 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1876 + where 1877 + St: label_value_definition_strings_state::State, 1878 + St::Description: label_value_definition_strings_state::IsUnset, 1879 + { 1880 + /// Set the `description` field (required) 1881 + pub fn description( 1882 + mut self, 1883 + value: impl Into<S>, 1884 + ) -> LabelValueDefinitionStringsBuilder< 1885 + S, 1886 + label_value_definition_strings_state::SetDescription<St>, 1887 + > { 1888 + self._fields.0 = ::core::option::Option::Some(value.into()); 1889 + LabelValueDefinitionStringsBuilder { 1890 + _state: ::core::marker::PhantomData, 1891 + _fields: self._fields, 1892 + _type: ::core::marker::PhantomData, 1893 + } 1894 + } 1895 + } 1896 + 1897 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1898 + where 1899 + St: label_value_definition_strings_state::State, 1900 + St::Lang: label_value_definition_strings_state::IsUnset, 1901 + { 1902 + /// Set the `lang` field (required) 1903 + pub fn lang( 1904 + mut self, 1905 + value: impl Into<jacquard_common::types::string::Language>, 1906 + ) -> LabelValueDefinitionStringsBuilder< 1907 + S, 1908 + label_value_definition_strings_state::SetLang<St>, 1909 + > { 1910 + self._fields.1 = ::core::option::Option::Some(value.into()); 1911 + LabelValueDefinitionStringsBuilder { 1912 + _state: ::core::marker::PhantomData, 1913 + _fields: self._fields, 1914 + _type: ::core::marker::PhantomData, 1915 + } 1916 + } 1917 + } 1918 + 1919 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1920 + where 1921 + St: label_value_definition_strings_state::State, 1922 + St::Name: label_value_definition_strings_state::IsUnset, 1923 + { 1924 + /// Set the `name` field (required) 1925 + pub fn name( 1926 + mut self, 1927 + value: impl Into<S>, 1928 + ) -> LabelValueDefinitionStringsBuilder< 1929 + S, 1930 + label_value_definition_strings_state::SetName<St>, 1931 + > { 1932 + self._fields.2 = ::core::option::Option::Some(value.into()); 1933 + LabelValueDefinitionStringsBuilder { 1934 + _state: ::core::marker::PhantomData, 1935 + _fields: self._fields, 1936 + _type: ::core::marker::PhantomData, 1937 + } 1938 + } 1939 + } 1940 + 1941 + impl<S: jacquard_common::BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1942 + where 1943 + St: label_value_definition_strings_state::State, 1944 + St::Lang: label_value_definition_strings_state::IsSet, 1945 + St::Name: label_value_definition_strings_state::IsSet, 1946 + St::Description: label_value_definition_strings_state::IsSet, 1947 + { 1948 + /// Build the final struct. 1949 + pub fn build(self) -> LabelValueDefinitionStrings<S> { 1950 + LabelValueDefinitionStrings { 1951 + description: self._fields.0.unwrap(), 1952 + lang: self._fields.1.unwrap(), 1953 + name: self._fields.2.unwrap(), 1954 + extra_data: Default::default(), 1955 + } 1956 + } 1957 + /// Build the final struct with custom extra_data. 1958 + pub fn build_with_data( 1959 + self, 1960 + extra_data: alloc::collections::BTreeMap< 1961 + jacquard_common::deps::smol_str::SmolStr, 1962 + jacquard_common::types::value::Data<S>, 1963 + >, 1964 + ) -> LabelValueDefinitionStrings<S> { 1965 + LabelValueDefinitionStrings { 1966 + description: self._fields.0.unwrap(), 1967 + lang: self._fields.1.unwrap(), 1968 + name: self._fields.2.unwrap(), 1969 + extra_data: Some(extra_data), 1970 + } 1971 + } 1972 + } 1973 + 1974 + pub mod self_labels_state { 1975 + 1976 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1977 + #[allow(unused)] 1978 + use ::core::marker::PhantomData; 1979 + mod sealed { 1980 + pub trait Sealed {} 1981 + } 1982 + /// State trait tracking which required fields have been set 1983 + pub trait State: sealed::Sealed { 1984 + type Values; 1985 + } 1986 + /// Empty state - all required fields are unset 1987 + pub struct Empty(()); 1988 + impl sealed::Sealed for Empty {} 1989 + impl State for Empty { 1990 + type Values = Unset; 1991 + } 1992 + ///State transition - sets the `values` field to Set 1993 + pub struct SetValues<St: State = Empty>(PhantomData<fn() -> St>); 1994 + impl<St: State> sealed::Sealed for SetValues<St> {} 1995 + impl<St: State> State for SetValues<St> { 1996 + type Values = Set<members::values>; 1997 + } 1998 + /// Marker types for field names 1999 + #[allow(non_camel_case_types)] 2000 + pub mod members { 2001 + ///Marker type for the `values` field 2002 + pub struct values(()); 2003 + } 2004 + } 2005 + 2006 + /// Builder for constructing an instance of this type. 2007 + pub struct SelfLabelsBuilder<S: jacquard_common::BosStr, St: self_labels_state::State> { 2008 + _state: ::core::marker::PhantomData<fn() -> St>, 2009 + _fields: ( 2010 + core::option::Option<Vec<crate::macro_mode::com_atproto::label::SelfLabel<S>>>, 2011 + ), 2012 + _type: ::core::marker::PhantomData<fn() -> S>, 2013 + } 2014 + 2015 + impl<S: jacquard_common::BosStr> SelfLabels<S> { 2016 + /// Create a new builder for this type. 2017 + pub fn new() -> SelfLabelsBuilder<S, self_labels_state::Empty> { 2018 + SelfLabelsBuilder::new() 2019 + } 2020 + } 2021 + 2022 + impl<S: jacquard_common::BosStr> SelfLabelsBuilder<S, self_labels_state::Empty> { 2023 + /// Create a new builder with all fields unset. 2024 + pub fn new() -> Self { 2025 + SelfLabelsBuilder { 2026 + _state: ::core::marker::PhantomData, 2027 + _fields: (None,), 2028 + _type: ::core::marker::PhantomData, 2029 + } 2030 + } 2031 + } 2032 + 2033 + impl<S: jacquard_common::BosStr, St> SelfLabelsBuilder<S, St> 2034 + where 2035 + St: self_labels_state::State, 2036 + St::Values: self_labels_state::IsUnset, 2037 + { 2038 + /// Set the `values` field (required) 2039 + pub fn values( 2040 + mut self, 2041 + value: impl Into<Vec<crate::macro_mode::com_atproto::label::SelfLabel<S>>>, 2042 + ) -> SelfLabelsBuilder<S, self_labels_state::SetValues<St>> { 2043 + self._fields.0 = ::core::option::Option::Some(value.into()); 2044 + SelfLabelsBuilder { 2045 + _state: ::core::marker::PhantomData, 2046 + _fields: self._fields, 2047 + _type: ::core::marker::PhantomData, 2048 + } 2049 + } 2050 + } 2051 + 2052 + impl<S: jacquard_common::BosStr, St> SelfLabelsBuilder<S, St> 2053 + where 2054 + St: self_labels_state::State, 2055 + St::Values: self_labels_state::IsSet, 2056 + { 2057 + /// Build the final struct. 2058 + pub fn build(self) -> SelfLabels<S> { 2059 + SelfLabels { 2060 + values: self._fields.0.unwrap(), 2061 + extra_data: Default::default(), 2062 + } 2063 + } 2064 + /// Build the final struct with custom extra_data. 2065 + pub fn build_with_data( 2066 + self, 2067 + extra_data: alloc::collections::BTreeMap< 2068 + jacquard_common::deps::smol_str::SmolStr, 2069 + jacquard_common::types::value::Data<S>, 2070 + >, 2071 + ) -> SelfLabels<S> { 2072 + SelfLabels { 2073 + values: self._fields.0.unwrap(), 2074 + extra_data: Some(extra_data), 2075 + } 2076 + } 2077 + }
+6
crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/repo.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod strong_ref;
+241
crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/repo/strong_ref.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: com.atproto.repo.strongRef 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 + jacquard_derive::IntoStatic 16 + )] 17 + 18 + #[serde( 19 + rename_all = "camelCase", 20 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 21 + )] 22 + pub struct StrongRef<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 23 + pub cid: jacquard_common::types::string::Cid<S>, 24 + pub uri: jacquard_common::types::string::AtUri<S>, 25 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 26 + pub extra_data: core::option::Option< 27 + alloc::collections::BTreeMap< 28 + jacquard_common::deps::smol_str::SmolStr, 29 + jacquard_common::types::value::Data<S>, 30 + >, 31 + >, 32 + } 33 + 34 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 35 + for StrongRef<S> { 36 + fn nsid() -> &'static str { 37 + "com.atproto.repo.strongRef" 38 + } 39 + fn def_name() -> &'static str { 40 + "main" 41 + } 42 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 43 + lexicon_doc_com_atproto_repo_strongRef() 44 + } 45 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 46 + Ok(()) 47 + } 48 + } 49 + 50 + pub mod strong_ref_state { 51 + 52 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 53 + #[allow(unused)] 54 + use ::core::marker::PhantomData; 55 + mod sealed { 56 + pub trait Sealed {} 57 + } 58 + /// State trait tracking which required fields have been set 59 + pub trait State: sealed::Sealed { 60 + type Cid; 61 + type Uri; 62 + } 63 + /// Empty state - all required fields are unset 64 + pub struct Empty(()); 65 + impl sealed::Sealed for Empty {} 66 + impl State for Empty { 67 + type Cid = Unset; 68 + type Uri = Unset; 69 + } 70 + ///State transition - sets the `cid` field to Set 71 + pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>); 72 + impl<St: State> sealed::Sealed for SetCid<St> {} 73 + impl<St: State> State for SetCid<St> { 74 + type Cid = Set<members::cid>; 75 + type Uri = St::Uri; 76 + } 77 + ///State transition - sets the `uri` field to Set 78 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 79 + impl<St: State> sealed::Sealed for SetUri<St> {} 80 + impl<St: State> State for SetUri<St> { 81 + type Cid = St::Cid; 82 + type Uri = Set<members::uri>; 83 + } 84 + /// Marker types for field names 85 + #[allow(non_camel_case_types)] 86 + pub mod members { 87 + ///Marker type for the `cid` field 88 + pub struct cid(()); 89 + ///Marker type for the `uri` field 90 + pub struct uri(()); 91 + } 92 + } 93 + 94 + /// Builder for constructing an instance of this type. 95 + pub struct StrongRefBuilder<S: jacquard_common::BosStr, St: strong_ref_state::State> { 96 + _state: ::core::marker::PhantomData<fn() -> St>, 97 + _fields: ( 98 + core::option::Option<jacquard_common::types::string::Cid<S>>, 99 + core::option::Option<jacquard_common::types::string::AtUri<S>>, 100 + ), 101 + _type: ::core::marker::PhantomData<fn() -> S>, 102 + } 103 + 104 + impl<S: jacquard_common::BosStr> StrongRef<S> { 105 + /// Create a new builder for this type. 106 + pub fn new() -> StrongRefBuilder<S, strong_ref_state::Empty> { 107 + StrongRefBuilder::new() 108 + } 109 + } 110 + 111 + impl<S: jacquard_common::BosStr> StrongRefBuilder<S, strong_ref_state::Empty> { 112 + /// Create a new builder with all fields unset. 113 + pub fn new() -> Self { 114 + StrongRefBuilder { 115 + _state: ::core::marker::PhantomData, 116 + _fields: (None, None), 117 + _type: ::core::marker::PhantomData, 118 + } 119 + } 120 + } 121 + 122 + impl<S: jacquard_common::BosStr, St> StrongRefBuilder<S, St> 123 + where 124 + St: strong_ref_state::State, 125 + St::Cid: strong_ref_state::IsUnset, 126 + { 127 + /// Set the `cid` field (required) 128 + pub fn cid( 129 + mut self, 130 + value: impl Into<jacquard_common::types::string::Cid<S>>, 131 + ) -> StrongRefBuilder<S, strong_ref_state::SetCid<St>> { 132 + self._fields.0 = ::core::option::Option::Some(value.into()); 133 + StrongRefBuilder { 134 + _state: ::core::marker::PhantomData, 135 + _fields: self._fields, 136 + _type: ::core::marker::PhantomData, 137 + } 138 + } 139 + } 140 + 141 + impl<S: jacquard_common::BosStr, St> StrongRefBuilder<S, St> 142 + where 143 + St: strong_ref_state::State, 144 + St::Uri: strong_ref_state::IsUnset, 145 + { 146 + /// Set the `uri` field (required) 147 + pub fn uri( 148 + mut self, 149 + value: impl Into<jacquard_common::types::string::AtUri<S>>, 150 + ) -> StrongRefBuilder<S, strong_ref_state::SetUri<St>> { 151 + self._fields.1 = ::core::option::Option::Some(value.into()); 152 + StrongRefBuilder { 153 + _state: ::core::marker::PhantomData, 154 + _fields: self._fields, 155 + _type: ::core::marker::PhantomData, 156 + } 157 + } 158 + } 159 + 160 + impl<S: jacquard_common::BosStr, St> StrongRefBuilder<S, St> 161 + where 162 + St: strong_ref_state::State, 163 + St::Cid: strong_ref_state::IsSet, 164 + St::Uri: strong_ref_state::IsSet, 165 + { 166 + /// Build the final struct. 167 + pub fn build(self) -> StrongRef<S> { 168 + StrongRef { 169 + cid: self._fields.0.unwrap(), 170 + uri: self._fields.1.unwrap(), 171 + extra_data: Default::default(), 172 + } 173 + } 174 + /// Build the final struct with custom extra_data. 175 + pub fn build_with_data( 176 + self, 177 + extra_data: alloc::collections::BTreeMap< 178 + jacquard_common::deps::smol_str::SmolStr, 179 + jacquard_common::types::value::Data<S>, 180 + >, 181 + ) -> StrongRef<S> { 182 + StrongRef { 183 + cid: self._fields.0.unwrap(), 184 + uri: self._fields.1.unwrap(), 185 + extra_data: Some(extra_data), 186 + } 187 + } 188 + } 189 + 190 + fn lexicon_doc_com_atproto_repo_strongRef() -> jacquard_lexicon::lexicon::LexiconDoc< 191 + 'static, 192 + > { 193 + ::jacquard_lexicon::lexicon::LexiconDoc { 194 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 195 + id: ::jacquard_common::CowStr::new_static("com.atproto.repo.strongRef"), 196 + defs: { 197 + let mut map = ::alloc::collections::BTreeMap::new(); 198 + map.insert( 199 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 200 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 201 + required: Some( 202 + vec![ 203 + ::jacquard_common::deps::smol_str::SmolStr::new_static("uri"), 204 + ::jacquard_common::deps::smol_str::SmolStr::new_static("cid") 205 + ], 206 + ), 207 + properties: { 208 + #[allow(unused_mut)] 209 + let mut map = ::alloc::collections::BTreeMap::new(); 210 + map.insert( 211 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 212 + "cid", 213 + ), 214 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 215 + format: Some( 216 + ::jacquard_lexicon::lexicon::LexStringFormat::Cid, 217 + ), 218 + ..Default::default() 219 + }), 220 + ); 221 + map.insert( 222 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 223 + "uri", 224 + ), 225 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 226 + format: Some( 227 + ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 228 + ), 229 + ..Default::default() 230 + }), 231 + ); 232 + map 233 + }, 234 + ..Default::default() 235 + }), 236 + ); 237 + map 238 + }, 239 + ..Default::default() 240 + } 241 + }
+30
crates/jacquard-codegen-tests/src/generated/macro_mode/lib.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + extern crate alloc; 7 + 8 + #[cfg(feature = "app_bsky")] 9 + pub mod app_bsky; 10 + pub mod builder_types; 11 + 12 + 13 + #[cfg(feature = "com_atproto")] 14 + pub mod com_atproto; 15 + 16 + 17 + #[cfg(feature = "test_collision")] 18 + pub mod test_collision; 19 + 20 + 21 + #[cfg(feature = "test_ns1")] 22 + pub mod test_ns1; 23 + 24 + 25 + #[cfg(feature = "test_ns2")] 26 + pub mod test_ns2; 27 + 28 + 29 + #[cfg(feature = "test_ns3")] 30 + pub mod test_ns3;
+8
crates/jacquard-codegen-tests/src/generated/macro_mode/test_collision.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod collection; 7 + pub mod did; 8 + pub mod option;
+486
crates/jacquard-codegen-tests/src/generated/macro_mode/test_collision/collection.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.collision.collection 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + /// A locally-defined type named Collection that collides with the trait import. 9 + 10 + #[derive( 11 + serde::Serialize, 12 + serde::Deserialize, 13 + Debug, 14 + Clone, 15 + PartialEq, 16 + Eq, 17 + jacquard_derive::IntoStatic, 18 + Default 19 + )] 20 + 21 + #[serde( 22 + rename_all = "camelCase", 23 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 24 + )] 25 + pub struct Collection<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 26 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 27 + pub count: core::option::Option<i64>, 28 + pub label: S, 29 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 30 + pub extra_data: core::option::Option< 31 + alloc::collections::BTreeMap< 32 + jacquard_common::deps::smol_str::SmolStr, 33 + jacquard_common::types::value::Data<S>, 34 + >, 35 + >, 36 + } 37 + 38 + /// A record that itself references the Collection trait via its NSID. 39 + 40 + #[derive( 41 + serde::Serialize, 42 + serde::Deserialize, 43 + Debug, 44 + Clone, 45 + PartialEq, 46 + Eq, 47 + jacquard_derive::IntoStatic 48 + )] 49 + 50 + #[serde( 51 + rename_all = "camelCase", 52 + rename = "test.collision.collection", 53 + tag = "$type", 54 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 55 + )] 56 + pub struct CollectionRecord<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 57 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 58 + pub created_at: core::option::Option<jacquard_common::types::string::Datetime>, 59 + pub items: Vec<crate::macro_mode::test_collision::collection::Collection<S>>, 60 + pub name: S, 61 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 62 + pub extra_data: core::option::Option< 63 + alloc::collections::BTreeMap< 64 + jacquard_common::deps::smol_str::SmolStr, 65 + jacquard_common::types::value::Data<S>, 66 + >, 67 + >, 68 + } 69 + 70 + /// Typed wrapper for GetRecord response with this collection's record type. 71 + 72 + #[derive( 73 + serde::Serialize, 74 + serde::Deserialize, 75 + Debug, 76 + Clone, 77 + PartialEq, 78 + Eq, 79 + jacquard_derive::IntoStatic 80 + )] 81 + 82 + #[serde(rename_all = "camelCase")] 83 + pub struct CollectionRecordGetRecordOutput< 84 + S: jacquard_common::BosStr = jacquard_common::DefaultStr, 85 + > { 86 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 87 + pub cid: core::option::Option<jacquard_common::types::string::Cid<S>>, 88 + pub uri: jacquard_common::types::string::AtUri<S>, 89 + pub value: CollectionRecord<S>, 90 + } 91 + 92 + impl<S: jacquard_common::BosStr> CollectionRecord<S> { 93 + pub fn uri( 94 + uri: S, 95 + ) -> Result< 96 + jacquard_common::types::uri::RecordUri<S, CollectionRecordRecord>, 97 + jacquard_common::types::uri::UriError, 98 + > { 99 + jacquard_common::types::uri::RecordUri::try_from_uri( 100 + jacquard_common::types::string::AtUri::new(uri)?, 101 + ) 102 + } 103 + } 104 + 105 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 106 + for Collection<S> { 107 + fn nsid() -> &'static str { 108 + "test.collision.collection" 109 + } 110 + fn def_name() -> &'static str { 111 + "collection" 112 + } 113 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 114 + lexicon_doc_test_collision_collection() 115 + } 116 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 117 + if let Some(ref value) = self.count { 118 + if *value < 0i64 { 119 + return Err(jacquard_lexicon::validation::ConstraintError::Minimum { 120 + path: jacquard_lexicon::validation::ValidationPath::from_field( 121 + "count", 122 + ), 123 + min: 0i64, 124 + actual: *value, 125 + }); 126 + } 127 + } 128 + { 129 + let value = &self.label; 130 + #[allow(unused_comparisons)] 131 + if <str>::len(value.as_ref()) > 100usize { 132 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 133 + path: jacquard_lexicon::validation::ValidationPath::from_field( 134 + "label", 135 + ), 136 + max: 100usize, 137 + actual: <str>::len(value.as_ref()), 138 + }); 139 + } 140 + } 141 + Ok(()) 142 + } 143 + } 144 + 145 + /// Marker type for deserializing records from this collection. 146 + 147 + #[derive(Debug, serde::Serialize, serde::Deserialize)] 148 + pub struct CollectionRecordRecord; 149 + impl jacquard_common::xrpc::XrpcResp for CollectionRecordRecord { 150 + const NSID: &'static str = "test.collision.collection"; 151 + const ENCODING: &'static str = "application/json"; 152 + type Output<S: jacquard_common::BosStr> = CollectionRecordGetRecordOutput<S>; 153 + type Err = jacquard_common::types::collection::RecordError; 154 + } 155 + 156 + impl<S: jacquard_common::BosStr> From<CollectionRecordGetRecordOutput<S>> 157 + for CollectionRecord<S> { 158 + fn from(output: CollectionRecordGetRecordOutput<S>) -> Self { 159 + output.value 160 + } 161 + } 162 + 163 + impl<S: jacquard_common::BosStr> jacquard_common::types::collection::Collection 164 + for CollectionRecord<S> { 165 + const NSID: &'static str = "test.collision.collection"; 166 + type Record = CollectionRecordRecord; 167 + } 168 + 169 + impl jacquard_common::types::collection::Collection for CollectionRecordRecord { 170 + const NSID: &'static str = "test.collision.collection"; 171 + type Record = CollectionRecordRecord; 172 + } 173 + 174 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 175 + for CollectionRecord<S> { 176 + fn nsid() -> &'static str { 177 + "test.collision.collection" 178 + } 179 + fn def_name() -> &'static str { 180 + "main" 181 + } 182 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 183 + lexicon_doc_test_collision_collection() 184 + } 185 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 186 + { 187 + let value = &self.name; 188 + #[allow(unused_comparisons)] 189 + if <str>::len(value.as_ref()) > 256usize { 190 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 191 + path: jacquard_lexicon::validation::ValidationPath::from_field( 192 + "name", 193 + ), 194 + max: 256usize, 195 + actual: <str>::len(value.as_ref()), 196 + }); 197 + } 198 + } 199 + Ok(()) 200 + } 201 + } 202 + 203 + fn lexicon_doc_test_collision_collection() -> jacquard_lexicon::lexicon::LexiconDoc< 204 + 'static, 205 + > { 206 + ::jacquard_lexicon::lexicon::LexiconDoc { 207 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 208 + id: ::jacquard_common::CowStr::new_static("test.collision.collection"), 209 + defs: { 210 + let mut map = ::alloc::collections::BTreeMap::new(); 211 + map.insert( 212 + ::jacquard_common::deps::smol_str::SmolStr::new_static("collection"), 213 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 214 + description: Some( 215 + ::jacquard_common::CowStr::new_static( 216 + "A locally-defined type named Collection that collides with the trait import.", 217 + ), 218 + ), 219 + required: Some( 220 + vec![ 221 + ::jacquard_common::deps::smol_str::SmolStr::new_static("label") 222 + ], 223 + ), 224 + properties: { 225 + #[allow(unused_mut)] 226 + let mut map = ::alloc::collections::BTreeMap::new(); 227 + map.insert( 228 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 229 + "count", 230 + ), 231 + ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 232 + minimum: Some(0i64), 233 + ..Default::default() 234 + }), 235 + ); 236 + map.insert( 237 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 238 + "label", 239 + ), 240 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 241 + max_length: Some(100usize), 242 + ..Default::default() 243 + }), 244 + ); 245 + map 246 + }, 247 + ..Default::default() 248 + }), 249 + ); 250 + map.insert( 251 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 252 + ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { 253 + description: Some( 254 + ::jacquard_common::CowStr::new_static( 255 + "A record that itself references the Collection trait via its NSID.", 256 + ), 257 + ), 258 + key: Some(::jacquard_common::CowStr::new_static("tid")), 259 + record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { 260 + required: Some( 261 + vec![ 262 + ::jacquard_common::deps::smol_str::SmolStr::new_static("name"), 263 + ::jacquard_common::deps::smol_str::SmolStr::new_static("items") 264 + ], 265 + ), 266 + properties: { 267 + #[allow(unused_mut)] 268 + let mut map = ::alloc::collections::BTreeMap::new(); 269 + map.insert( 270 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 271 + "createdAt", 272 + ), 273 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 274 + format: Some( 275 + ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 276 + ), 277 + ..Default::default() 278 + }), 279 + ); 280 + map.insert( 281 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 282 + "items", 283 + ), 284 + ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 285 + items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 286 + r#ref: ::jacquard_common::CowStr::new_static("#collection"), 287 + ..Default::default() 288 + }), 289 + ..Default::default() 290 + }), 291 + ); 292 + map.insert( 293 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 294 + "name", 295 + ), 296 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 297 + max_length: Some(256usize), 298 + ..Default::default() 299 + }), 300 + ); 301 + map 302 + }, 303 + ..Default::default() 304 + }), 305 + ..Default::default() 306 + }), 307 + ); 308 + map 309 + }, 310 + ..Default::default() 311 + } 312 + } 313 + 314 + pub mod collection_record_state { 315 + 316 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 317 + #[allow(unused)] 318 + use ::core::marker::PhantomData; 319 + mod sealed { 320 + pub trait Sealed {} 321 + } 322 + /// State trait tracking which required fields have been set 323 + pub trait State: sealed::Sealed { 324 + type Items; 325 + type Name; 326 + } 327 + /// Empty state - all required fields are unset 328 + pub struct Empty(()); 329 + impl sealed::Sealed for Empty {} 330 + impl State for Empty { 331 + type Items = Unset; 332 + type Name = Unset; 333 + } 334 + ///State transition - sets the `items` field to Set 335 + pub struct SetItems<St: State = Empty>(PhantomData<fn() -> St>); 336 + impl<St: State> sealed::Sealed for SetItems<St> {} 337 + impl<St: State> State for SetItems<St> { 338 + type Items = Set<members::items>; 339 + type Name = St::Name; 340 + } 341 + ///State transition - sets the `name` field to Set 342 + pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>); 343 + impl<St: State> sealed::Sealed for SetName<St> {} 344 + impl<St: State> State for SetName<St> { 345 + type Items = St::Items; 346 + type Name = Set<members::name>; 347 + } 348 + /// Marker types for field names 349 + #[allow(non_camel_case_types)] 350 + pub mod members { 351 + ///Marker type for the `items` field 352 + pub struct items(()); 353 + ///Marker type for the `name` field 354 + pub struct name(()); 355 + } 356 + } 357 + 358 + /// Builder for constructing an instance of this type. 359 + pub struct CollectionRecordBuilder< 360 + S: jacquard_common::BosStr, 361 + St: collection_record_state::State, 362 + > { 363 + _state: ::core::marker::PhantomData<fn() -> St>, 364 + _fields: ( 365 + core::option::Option<jacquard_common::types::string::Datetime>, 366 + core::option::Option< 367 + Vec<crate::macro_mode::test_collision::collection::Collection<S>>, 368 + >, 369 + core::option::Option<S>, 370 + ), 371 + _type: ::core::marker::PhantomData<fn() -> S>, 372 + } 373 + 374 + impl<S: jacquard_common::BosStr> CollectionRecord<S> { 375 + /// Create a new builder for this type. 376 + pub fn new() -> CollectionRecordBuilder<S, collection_record_state::Empty> { 377 + CollectionRecordBuilder::new() 378 + } 379 + } 380 + 381 + impl< 382 + S: jacquard_common::BosStr, 383 + > CollectionRecordBuilder<S, collection_record_state::Empty> { 384 + /// Create a new builder with all fields unset. 385 + pub fn new() -> Self { 386 + CollectionRecordBuilder { 387 + _state: ::core::marker::PhantomData, 388 + _fields: (None, None, None), 389 + _type: ::core::marker::PhantomData, 390 + } 391 + } 392 + } 393 + 394 + impl< 395 + S: jacquard_common::BosStr, 396 + St: collection_record_state::State, 397 + > CollectionRecordBuilder<S, St> { 398 + /// Set the `createdAt` field (optional) 399 + pub fn created_at( 400 + mut self, 401 + value: impl Into<Option<jacquard_common::types::string::Datetime>>, 402 + ) -> Self { 403 + self._fields.0 = value.into(); 404 + self 405 + } 406 + /// Set the `createdAt` field to an Option value (optional) 407 + pub fn maybe_created_at( 408 + mut self, 409 + value: Option<jacquard_common::types::string::Datetime>, 410 + ) -> Self { 411 + self._fields.0 = value; 412 + self 413 + } 414 + } 415 + 416 + impl<S: jacquard_common::BosStr, St> CollectionRecordBuilder<S, St> 417 + where 418 + St: collection_record_state::State, 419 + St::Items: collection_record_state::IsUnset, 420 + { 421 + /// Set the `items` field (required) 422 + pub fn items( 423 + mut self, 424 + value: impl Into< 425 + Vec<crate::macro_mode::test_collision::collection::Collection<S>>, 426 + >, 427 + ) -> CollectionRecordBuilder<S, collection_record_state::SetItems<St>> { 428 + self._fields.1 = ::core::option::Option::Some(value.into()); 429 + CollectionRecordBuilder { 430 + _state: ::core::marker::PhantomData, 431 + _fields: self._fields, 432 + _type: ::core::marker::PhantomData, 433 + } 434 + } 435 + } 436 + 437 + impl<S: jacquard_common::BosStr, St> CollectionRecordBuilder<S, St> 438 + where 439 + St: collection_record_state::State, 440 + St::Name: collection_record_state::IsUnset, 441 + { 442 + /// Set the `name` field (required) 443 + pub fn name( 444 + mut self, 445 + value: impl Into<S>, 446 + ) -> CollectionRecordBuilder<S, collection_record_state::SetName<St>> { 447 + self._fields.2 = ::core::option::Option::Some(value.into()); 448 + CollectionRecordBuilder { 449 + _state: ::core::marker::PhantomData, 450 + _fields: self._fields, 451 + _type: ::core::marker::PhantomData, 452 + } 453 + } 454 + } 455 + 456 + impl<S: jacquard_common::BosStr, St> CollectionRecordBuilder<S, St> 457 + where 458 + St: collection_record_state::State, 459 + St::Items: collection_record_state::IsSet, 460 + St::Name: collection_record_state::IsSet, 461 + { 462 + /// Build the final struct. 463 + pub fn build(self) -> CollectionRecord<S> { 464 + CollectionRecord { 465 + created_at: self._fields.0, 466 + items: self._fields.1.unwrap(), 467 + name: self._fields.2.unwrap(), 468 + extra_data: Default::default(), 469 + } 470 + } 471 + /// Build the final struct with custom extra_data. 472 + pub fn build_with_data( 473 + self, 474 + extra_data: alloc::collections::BTreeMap< 475 + jacquard_common::deps::smol_str::SmolStr, 476 + jacquard_common::types::value::Data<S>, 477 + >, 478 + ) -> CollectionRecord<S> { 479 + CollectionRecord { 480 + created_at: self._fields.0, 481 + items: self._fields.1.unwrap(), 482 + name: self._fields.2.unwrap(), 483 + extra_data: Some(extra_data), 484 + } 485 + } 486 + }
+411
crates/jacquard-codegen-tests/src/generated/macro_mode/test_collision/did.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.collision.did 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + /// A locally-defined type named Did that collides with the string import. 9 + 10 + #[derive( 11 + serde::Serialize, 12 + serde::Deserialize, 13 + Debug, 14 + Clone, 15 + PartialEq, 16 + Eq, 17 + jacquard_derive::IntoStatic, 18 + Default 19 + )] 20 + 21 + #[serde( 22 + rename_all = "camelCase", 23 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 24 + )] 25 + pub struct Did<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 26 + ///The DID method (e.g., plc, web). 27 + pub method: S, 28 + ///The full DID string. 29 + pub value: 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 + 39 + /// An object that also uses a DID-format string field, exercising the collision path. 40 + 41 + #[derive( 42 + serde::Serialize, 43 + serde::Deserialize, 44 + Debug, 45 + Clone, 46 + PartialEq, 47 + Eq, 48 + jacquard_derive::IntoStatic 49 + )] 50 + 51 + #[serde( 52 + rename_all = "camelCase", 53 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 54 + )] 55 + pub struct DidRecord<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 56 + pub identifier: crate::macro_mode::test_collision::did::Did<S>, 57 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 58 + pub label: core::option::Option<S>, 59 + ///A field typed as DID format, requiring the Did import but colliding with local Did type. 60 + pub owner: jacquard_common::types::string::Did<S>, 61 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 62 + pub extra_data: core::option::Option< 63 + alloc::collections::BTreeMap< 64 + jacquard_common::deps::smol_str::SmolStr, 65 + jacquard_common::types::value::Data<S>, 66 + >, 67 + >, 68 + } 69 + 70 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Did<S> { 71 + fn nsid() -> &'static str { 72 + "test.collision.did" 73 + } 74 + fn def_name() -> &'static str { 75 + "did" 76 + } 77 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 78 + lexicon_doc_test_collision_did() 79 + } 80 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 81 + { 82 + let value = &self.method; 83 + #[allow(unused_comparisons)] 84 + if <str>::len(value.as_ref()) > 50usize { 85 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 86 + path: jacquard_lexicon::validation::ValidationPath::from_field( 87 + "method", 88 + ), 89 + max: 50usize, 90 + actual: <str>::len(value.as_ref()), 91 + }); 92 + } 93 + } 94 + { 95 + let value = &self.value; 96 + #[allow(unused_comparisons)] 97 + if <str>::len(value.as_ref()) > 256usize { 98 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 99 + path: jacquard_lexicon::validation::ValidationPath::from_field( 100 + "value", 101 + ), 102 + max: 256usize, 103 + actual: <str>::len(value.as_ref()), 104 + }); 105 + } 106 + } 107 + Ok(()) 108 + } 109 + } 110 + 111 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 112 + for DidRecord<S> { 113 + fn nsid() -> &'static str { 114 + "test.collision.did" 115 + } 116 + fn def_name() -> &'static str { 117 + "main" 118 + } 119 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 120 + lexicon_doc_test_collision_did() 121 + } 122 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 123 + if let Some(ref value) = self.label { 124 + #[allow(unused_comparisons)] 125 + if <str>::len(value.as_ref()) > 200usize { 126 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 127 + path: jacquard_lexicon::validation::ValidationPath::from_field( 128 + "label", 129 + ), 130 + max: 200usize, 131 + actual: <str>::len(value.as_ref()), 132 + }); 133 + } 134 + } 135 + Ok(()) 136 + } 137 + } 138 + 139 + fn lexicon_doc_test_collision_did() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 140 + ::jacquard_lexicon::lexicon::LexiconDoc { 141 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 142 + id: ::jacquard_common::CowStr::new_static("test.collision.did"), 143 + defs: { 144 + let mut map = ::alloc::collections::BTreeMap::new(); 145 + map.insert( 146 + ::jacquard_common::deps::smol_str::SmolStr::new_static("did"), 147 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 148 + description: Some( 149 + ::jacquard_common::CowStr::new_static( 150 + "A locally-defined type named Did that collides with the string import.", 151 + ), 152 + ), 153 + required: Some( 154 + vec![ 155 + ::jacquard_common::deps::smol_str::SmolStr::new_static("method"), 156 + ::jacquard_common::deps::smol_str::SmolStr::new_static("value") 157 + ], 158 + ), 159 + properties: { 160 + #[allow(unused_mut)] 161 + let mut map = ::alloc::collections::BTreeMap::new(); 162 + map.insert( 163 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 164 + "method", 165 + ), 166 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 167 + description: Some( 168 + ::jacquard_common::CowStr::new_static( 169 + "The DID method (e.g., plc, web).", 170 + ), 171 + ), 172 + max_length: Some(50usize), 173 + ..Default::default() 174 + }), 175 + ); 176 + map.insert( 177 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 178 + "value", 179 + ), 180 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 181 + description: Some( 182 + ::jacquard_common::CowStr::new_static( 183 + "The full DID string.", 184 + ), 185 + ), 186 + max_length: Some(256usize), 187 + ..Default::default() 188 + }), 189 + ); 190 + map 191 + }, 192 + ..Default::default() 193 + }), 194 + ); 195 + map.insert( 196 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 197 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 198 + description: Some( 199 + ::jacquard_common::CowStr::new_static( 200 + "An object that also uses a DID-format string field, exercising the collision path.", 201 + ), 202 + ), 203 + required: Some( 204 + vec![ 205 + ::jacquard_common::deps::smol_str::SmolStr::new_static("owner"), 206 + ::jacquard_common::deps::smol_str::SmolStr::new_static("identifier") 207 + ], 208 + ), 209 + properties: { 210 + #[allow(unused_mut)] 211 + let mut map = ::alloc::collections::BTreeMap::new(); 212 + map.insert( 213 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 214 + "identifier", 215 + ), 216 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 217 + r#ref: ::jacquard_common::CowStr::new_static("#did"), 218 + ..Default::default() 219 + }), 220 + ); 221 + map.insert( 222 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 223 + "label", 224 + ), 225 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 226 + max_length: Some(200usize), 227 + ..Default::default() 228 + }), 229 + ); 230 + map.insert( 231 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 232 + "owner", 233 + ), 234 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 235 + description: Some( 236 + ::jacquard_common::CowStr::new_static( 237 + "A field typed as DID format, requiring the Did import but colliding with local Did type.", 238 + ), 239 + ), 240 + format: Some( 241 + ::jacquard_lexicon::lexicon::LexStringFormat::Did, 242 + ), 243 + ..Default::default() 244 + }), 245 + ); 246 + map 247 + }, 248 + ..Default::default() 249 + }), 250 + ); 251 + map 252 + }, 253 + ..Default::default() 254 + } 255 + } 256 + 257 + pub mod did_record_state { 258 + 259 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 260 + #[allow(unused)] 261 + use ::core::marker::PhantomData; 262 + mod sealed { 263 + pub trait Sealed {} 264 + } 265 + /// State trait tracking which required fields have been set 266 + pub trait State: sealed::Sealed { 267 + type Identifier; 268 + type Owner; 269 + } 270 + /// Empty state - all required fields are unset 271 + pub struct Empty(()); 272 + impl sealed::Sealed for Empty {} 273 + impl State for Empty { 274 + type Identifier = Unset; 275 + type Owner = Unset; 276 + } 277 + ///State transition - sets the `identifier` field to Set 278 + pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>); 279 + impl<St: State> sealed::Sealed for SetIdentifier<St> {} 280 + impl<St: State> State for SetIdentifier<St> { 281 + type Identifier = Set<members::identifier>; 282 + type Owner = St::Owner; 283 + } 284 + ///State transition - sets the `owner` field to Set 285 + pub struct SetOwner<St: State = Empty>(PhantomData<fn() -> St>); 286 + impl<St: State> sealed::Sealed for SetOwner<St> {} 287 + impl<St: State> State for SetOwner<St> { 288 + type Identifier = St::Identifier; 289 + type Owner = Set<members::owner>; 290 + } 291 + /// Marker types for field names 292 + #[allow(non_camel_case_types)] 293 + pub mod members { 294 + ///Marker type for the `identifier` field 295 + pub struct identifier(()); 296 + ///Marker type for the `owner` field 297 + pub struct owner(()); 298 + } 299 + } 300 + 301 + /// Builder for constructing an instance of this type. 302 + pub struct DidRecordBuilder<S: jacquard_common::BosStr, St: did_record_state::State> { 303 + _state: ::core::marker::PhantomData<fn() -> St>, 304 + _fields: ( 305 + core::option::Option<crate::macro_mode::test_collision::did::Did<S>>, 306 + core::option::Option<S>, 307 + core::option::Option<jacquard_common::types::string::Did<S>>, 308 + ), 309 + _type: ::core::marker::PhantomData<fn() -> S>, 310 + } 311 + 312 + impl<S: jacquard_common::BosStr> DidRecord<S> { 313 + /// Create a new builder for this type. 314 + pub fn new() -> DidRecordBuilder<S, did_record_state::Empty> { 315 + DidRecordBuilder::new() 316 + } 317 + } 318 + 319 + impl<S: jacquard_common::BosStr> DidRecordBuilder<S, did_record_state::Empty> { 320 + /// Create a new builder with all fields unset. 321 + pub fn new() -> Self { 322 + DidRecordBuilder { 323 + _state: ::core::marker::PhantomData, 324 + _fields: (None, None, None), 325 + _type: ::core::marker::PhantomData, 326 + } 327 + } 328 + } 329 + 330 + impl<S: jacquard_common::BosStr, St> DidRecordBuilder<S, St> 331 + where 332 + St: did_record_state::State, 333 + St::Identifier: did_record_state::IsUnset, 334 + { 335 + /// Set the `identifier` field (required) 336 + pub fn identifier( 337 + mut self, 338 + value: impl Into<crate::macro_mode::test_collision::did::Did<S>>, 339 + ) -> DidRecordBuilder<S, did_record_state::SetIdentifier<St>> { 340 + self._fields.0 = ::core::option::Option::Some(value.into()); 341 + DidRecordBuilder { 342 + _state: ::core::marker::PhantomData, 343 + _fields: self._fields, 344 + _type: ::core::marker::PhantomData, 345 + } 346 + } 347 + } 348 + 349 + impl<S: jacquard_common::BosStr, St: did_record_state::State> DidRecordBuilder<S, St> { 350 + /// Set the `label` field (optional) 351 + pub fn label(mut self, value: impl Into<Option<S>>) -> Self { 352 + self._fields.1 = value.into(); 353 + self 354 + } 355 + /// Set the `label` field to an Option value (optional) 356 + pub fn maybe_label(mut self, value: Option<S>) -> Self { 357 + self._fields.1 = value; 358 + self 359 + } 360 + } 361 + 362 + impl<S: jacquard_common::BosStr, St> DidRecordBuilder<S, St> 363 + where 364 + St: did_record_state::State, 365 + St::Owner: did_record_state::IsUnset, 366 + { 367 + /// Set the `owner` field (required) 368 + pub fn owner( 369 + mut self, 370 + value: impl Into<jacquard_common::types::string::Did<S>>, 371 + ) -> DidRecordBuilder<S, did_record_state::SetOwner<St>> { 372 + self._fields.2 = ::core::option::Option::Some(value.into()); 373 + DidRecordBuilder { 374 + _state: ::core::marker::PhantomData, 375 + _fields: self._fields, 376 + _type: ::core::marker::PhantomData, 377 + } 378 + } 379 + } 380 + 381 + impl<S: jacquard_common::BosStr, St> DidRecordBuilder<S, St> 382 + where 383 + St: did_record_state::State, 384 + St::Identifier: did_record_state::IsSet, 385 + St::Owner: did_record_state::IsSet, 386 + { 387 + /// Build the final struct. 388 + pub fn build(self) -> DidRecord<S> { 389 + DidRecord { 390 + identifier: self._fields.0.unwrap(), 391 + label: self._fields.1, 392 + owner: self._fields.2.unwrap(), 393 + extra_data: Default::default(), 394 + } 395 + } 396 + /// Build the final struct with custom extra_data. 397 + pub fn build_with_data( 398 + self, 399 + extra_data: alloc::collections::BTreeMap< 400 + jacquard_common::deps::smol_str::SmolStr, 401 + jacquard_common::types::value::Data<S>, 402 + >, 403 + ) -> DidRecord<S> { 404 + DidRecord { 405 + identifier: self._fields.0.unwrap(), 406 + label: self._fields.1, 407 + owner: self._fields.2.unwrap(), 408 + extra_data: Some(extra_data), 409 + } 410 + } 411 + }
+358
crates/jacquard-codegen-tests/src/generated/macro_mode/test_collision/option.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.collision.option 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 with optional fields, exercising the Option::is_none path collision. 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 + )] 24 + pub struct OptionRecord<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 25 + pub choice: crate::macro_mode::test_collision::option::OptionRecordOption<S>, 26 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 27 + pub description: core::option::Option<S>, 28 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 29 + pub extra_data: core::option::Option< 30 + alloc::collections::BTreeMap< 31 + jacquard_common::deps::smol_str::SmolStr, 32 + jacquard_common::types::value::Data<S>, 33 + >, 34 + >, 35 + } 36 + 37 + /// A locally-defined type named Option, colliding with std::option::Option. 38 + 39 + #[derive( 40 + serde::Serialize, 41 + serde::Deserialize, 42 + Debug, 43 + Clone, 44 + PartialEq, 45 + Eq, 46 + jacquard_derive::IntoStatic, 47 + Default 48 + )] 49 + 50 + #[serde( 51 + rename_all = "camelCase", 52 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 53 + )] 54 + pub struct OptionRecordOption<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 55 + pub key: S, 56 + pub value: S, 57 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 58 + pub extra_data: core::option::Option< 59 + alloc::collections::BTreeMap< 60 + jacquard_common::deps::smol_str::SmolStr, 61 + jacquard_common::types::value::Data<S>, 62 + >, 63 + >, 64 + } 65 + 66 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 67 + for OptionRecord<S> { 68 + fn nsid() -> &'static str { 69 + "test.collision.option" 70 + } 71 + fn def_name() -> &'static str { 72 + "main" 73 + } 74 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 75 + lexicon_doc_test_collision_option() 76 + } 77 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 78 + if let Some(ref value) = self.description { 79 + #[allow(unused_comparisons)] 80 + if <str>::len(value.as_ref()) > 500usize { 81 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 82 + path: jacquard_lexicon::validation::ValidationPath::from_field( 83 + "description", 84 + ), 85 + max: 500usize, 86 + actual: <str>::len(value.as_ref()), 87 + }); 88 + } 89 + } 90 + Ok(()) 91 + } 92 + } 93 + 94 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 95 + for OptionRecordOption<S> { 96 + fn nsid() -> &'static str { 97 + "test.collision.option" 98 + } 99 + fn def_name() -> &'static str { 100 + "option" 101 + } 102 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 103 + lexicon_doc_test_collision_option() 104 + } 105 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 106 + { 107 + let value = &self.key; 108 + #[allow(unused_comparisons)] 109 + if <str>::len(value.as_ref()) > 100usize { 110 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 111 + path: jacquard_lexicon::validation::ValidationPath::from_field( 112 + "key", 113 + ), 114 + max: 100usize, 115 + actual: <str>::len(value.as_ref()), 116 + }); 117 + } 118 + } 119 + { 120 + let value = &self.value; 121 + #[allow(unused_comparisons)] 122 + if <str>::len(value.as_ref()) > 500usize { 123 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 124 + path: jacquard_lexicon::validation::ValidationPath::from_field( 125 + "value", 126 + ), 127 + max: 500usize, 128 + actual: <str>::len(value.as_ref()), 129 + }); 130 + } 131 + } 132 + Ok(()) 133 + } 134 + } 135 + 136 + pub mod option_record_state { 137 + 138 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 139 + #[allow(unused)] 140 + use ::core::marker::PhantomData; 141 + mod sealed { 142 + pub trait Sealed {} 143 + } 144 + /// State trait tracking which required fields have been set 145 + pub trait State: sealed::Sealed { 146 + type Choice; 147 + } 148 + /// Empty state - all required fields are unset 149 + pub struct Empty(()); 150 + impl sealed::Sealed for Empty {} 151 + impl State for Empty { 152 + type Choice = Unset; 153 + } 154 + ///State transition - sets the `choice` field to Set 155 + pub struct SetChoice<St: State = Empty>(PhantomData<fn() -> St>); 156 + impl<St: State> sealed::Sealed for SetChoice<St> {} 157 + impl<St: State> State for SetChoice<St> { 158 + type Choice = Set<members::choice>; 159 + } 160 + /// Marker types for field names 161 + #[allow(non_camel_case_types)] 162 + pub mod members { 163 + ///Marker type for the `choice` field 164 + pub struct choice(()); 165 + } 166 + } 167 + 168 + /// Builder for constructing an instance of this type. 169 + pub struct OptionRecordBuilder< 170 + S: jacquard_common::BosStr, 171 + St: option_record_state::State, 172 + > { 173 + _state: ::core::marker::PhantomData<fn() -> St>, 174 + _fields: ( 175 + core::option::Option< 176 + crate::macro_mode::test_collision::option::OptionRecordOption<S>, 177 + >, 178 + core::option::Option<S>, 179 + ), 180 + _type: ::core::marker::PhantomData<fn() -> S>, 181 + } 182 + 183 + impl<S: jacquard_common::BosStr> OptionRecord<S> { 184 + /// Create a new builder for this type. 185 + pub fn new() -> OptionRecordBuilder<S, option_record_state::Empty> { 186 + OptionRecordBuilder::new() 187 + } 188 + } 189 + 190 + impl<S: jacquard_common::BosStr> OptionRecordBuilder<S, option_record_state::Empty> { 191 + /// Create a new builder with all fields unset. 192 + pub fn new() -> Self { 193 + OptionRecordBuilder { 194 + _state: ::core::marker::PhantomData, 195 + _fields: (None, None), 196 + _type: ::core::marker::PhantomData, 197 + } 198 + } 199 + } 200 + 201 + impl<S: jacquard_common::BosStr, St> OptionRecordBuilder<S, St> 202 + where 203 + St: option_record_state::State, 204 + St::Choice: option_record_state::IsUnset, 205 + { 206 + /// Set the `choice` field (required) 207 + pub fn choice( 208 + mut self, 209 + value: impl Into< 210 + crate::macro_mode::test_collision::option::OptionRecordOption<S>, 211 + >, 212 + ) -> OptionRecordBuilder<S, option_record_state::SetChoice<St>> { 213 + self._fields.0 = ::core::option::Option::Some(value.into()); 214 + OptionRecordBuilder { 215 + _state: ::core::marker::PhantomData, 216 + _fields: self._fields, 217 + _type: ::core::marker::PhantomData, 218 + } 219 + } 220 + } 221 + 222 + impl< 223 + S: jacquard_common::BosStr, 224 + St: option_record_state::State, 225 + > OptionRecordBuilder<S, St> { 226 + /// Set the `description` field (optional) 227 + pub fn description(mut self, value: impl Into<Option<S>>) -> Self { 228 + self._fields.1 = value.into(); 229 + self 230 + } 231 + /// Set the `description` field to an Option value (optional) 232 + pub fn maybe_description(mut self, value: Option<S>) -> Self { 233 + self._fields.1 = value; 234 + self 235 + } 236 + } 237 + 238 + impl<S: jacquard_common::BosStr, St> OptionRecordBuilder<S, St> 239 + where 240 + St: option_record_state::State, 241 + St::Choice: option_record_state::IsSet, 242 + { 243 + /// Build the final struct. 244 + pub fn build(self) -> OptionRecord<S> { 245 + OptionRecord { 246 + choice: self._fields.0.unwrap(), 247 + description: self._fields.1, 248 + extra_data: Default::default(), 249 + } 250 + } 251 + /// Build the final struct with custom extra_data. 252 + pub fn build_with_data( 253 + self, 254 + extra_data: alloc::collections::BTreeMap< 255 + jacquard_common::deps::smol_str::SmolStr, 256 + jacquard_common::types::value::Data<S>, 257 + >, 258 + ) -> OptionRecord<S> { 259 + OptionRecord { 260 + choice: self._fields.0.unwrap(), 261 + description: self._fields.1, 262 + extra_data: Some(extra_data), 263 + } 264 + } 265 + } 266 + 267 + fn lexicon_doc_test_collision_option() -> jacquard_lexicon::lexicon::LexiconDoc< 268 + 'static, 269 + > { 270 + ::jacquard_lexicon::lexicon::LexiconDoc { 271 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 272 + id: ::jacquard_common::CowStr::new_static("test.collision.option"), 273 + defs: { 274 + let mut map = ::alloc::collections::BTreeMap::new(); 275 + map.insert( 276 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 277 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 278 + description: Some( 279 + ::jacquard_common::CowStr::new_static( 280 + "An object with optional fields, exercising the Option::is_none path collision.", 281 + ), 282 + ), 283 + required: Some( 284 + vec![ 285 + ::jacquard_common::deps::smol_str::SmolStr::new_static("choice") 286 + ], 287 + ), 288 + properties: { 289 + #[allow(unused_mut)] 290 + let mut map = ::alloc::collections::BTreeMap::new(); 291 + map.insert( 292 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 293 + "choice", 294 + ), 295 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 296 + r#ref: ::jacquard_common::CowStr::new_static("#option"), 297 + ..Default::default() 298 + }), 299 + ); 300 + map.insert( 301 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 302 + "description", 303 + ), 304 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 305 + max_length: Some(500usize), 306 + ..Default::default() 307 + }), 308 + ); 309 + map 310 + }, 311 + ..Default::default() 312 + }), 313 + ); 314 + map.insert( 315 + ::jacquard_common::deps::smol_str::SmolStr::new_static("option"), 316 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 317 + description: Some( 318 + ::jacquard_common::CowStr::new_static( 319 + "A locally-defined type named Option, colliding with std::option::Option.", 320 + ), 321 + ), 322 + required: Some( 323 + vec![ 324 + ::jacquard_common::deps::smol_str::SmolStr::new_static("key"), 325 + ::jacquard_common::deps::smol_str::SmolStr::new_static("value") 326 + ], 327 + ), 328 + properties: { 329 + #[allow(unused_mut)] 330 + let mut map = ::alloc::collections::BTreeMap::new(); 331 + map.insert( 332 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 333 + "key", 334 + ), 335 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 336 + max_length: Some(100usize), 337 + ..Default::default() 338 + }), 339 + ); 340 + map.insert( 341 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 342 + "value", 343 + ), 344 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 345 + max_length: Some(500usize), 346 + ..Default::default() 347 + }), 348 + ); 349 + map 350 + }, 351 + ..Default::default() 352 + }), 353 + ); 354 + map 355 + }, 356 + ..Default::default() 357 + } 358 + }
+200
crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns1.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.ns1.defs 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + /// Another type in ns1 for cross-namespace ref testing. 9 + 10 + #[derive( 11 + serde::Serialize, 12 + serde::Deserialize, 13 + Debug, 14 + Clone, 15 + PartialEq, 16 + Eq, 17 + jacquard_derive::IntoStatic, 18 + Default 19 + )] 20 + 21 + #[serde( 22 + rename_all = "camelCase", 23 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 24 + )] 25 + pub struct Bar<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 26 + pub tag: S, 27 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 28 + pub extra_data: core::option::Option< 29 + alloc::collections::BTreeMap< 30 + jacquard_common::deps::smol_str::SmolStr, 31 + jacquard_common::types::value::Data<S>, 32 + >, 33 + >, 34 + } 35 + 36 + /// A type defined in ns1, referenced cross-namespace by ns2. 37 + 38 + #[derive( 39 + serde::Serialize, 40 + serde::Deserialize, 41 + Debug, 42 + Clone, 43 + PartialEq, 44 + Eq, 45 + jacquard_derive::IntoStatic, 46 + Default 47 + )] 48 + 49 + #[serde( 50 + rename_all = "camelCase", 51 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 52 + )] 53 + pub struct Foo<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 54 + pub name: S, 55 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 56 + pub value: core::option::Option<i64>, 57 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 58 + pub extra_data: core::option::Option< 59 + alloc::collections::BTreeMap< 60 + jacquard_common::deps::smol_str::SmolStr, 61 + jacquard_common::types::value::Data<S>, 62 + >, 63 + >, 64 + } 65 + 66 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Bar<S> { 67 + fn nsid() -> &'static str { 68 + "test.ns1.defs" 69 + } 70 + fn def_name() -> &'static str { 71 + "bar" 72 + } 73 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 74 + lexicon_doc_test_ns1_defs() 75 + } 76 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 77 + { 78 + let value = &self.tag; 79 + #[allow(unused_comparisons)] 80 + if <str>::len(value.as_ref()) > 50usize { 81 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 82 + path: jacquard_lexicon::validation::ValidationPath::from_field( 83 + "tag", 84 + ), 85 + max: 50usize, 86 + actual: <str>::len(value.as_ref()), 87 + }); 88 + } 89 + } 90 + Ok(()) 91 + } 92 + } 93 + 94 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Foo<S> { 95 + fn nsid() -> &'static str { 96 + "test.ns1.defs" 97 + } 98 + fn def_name() -> &'static str { 99 + "foo" 100 + } 101 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 102 + lexicon_doc_test_ns1_defs() 103 + } 104 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 105 + { 106 + let value = &self.name; 107 + #[allow(unused_comparisons)] 108 + if <str>::len(value.as_ref()) > 100usize { 109 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 110 + path: jacquard_lexicon::validation::ValidationPath::from_field( 111 + "name", 112 + ), 113 + max: 100usize, 114 + actual: <str>::len(value.as_ref()), 115 + }); 116 + } 117 + } 118 + Ok(()) 119 + } 120 + } 121 + 122 + fn lexicon_doc_test_ns1_defs() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 123 + ::jacquard_lexicon::lexicon::LexiconDoc { 124 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 125 + id: ::jacquard_common::CowStr::new_static("test.ns1.defs"), 126 + defs: { 127 + let mut map = ::alloc::collections::BTreeMap::new(); 128 + map.insert( 129 + ::jacquard_common::deps::smol_str::SmolStr::new_static("bar"), 130 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 131 + description: Some( 132 + ::jacquard_common::CowStr::new_static( 133 + "Another type in ns1 for cross-namespace ref testing.", 134 + ), 135 + ), 136 + required: Some( 137 + vec![ 138 + ::jacquard_common::deps::smol_str::SmolStr::new_static("tag") 139 + ], 140 + ), 141 + properties: { 142 + #[allow(unused_mut)] 143 + let mut map = ::alloc::collections::BTreeMap::new(); 144 + map.insert( 145 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 146 + "tag", 147 + ), 148 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 149 + max_length: Some(50usize), 150 + ..Default::default() 151 + }), 152 + ); 153 + map 154 + }, 155 + ..Default::default() 156 + }), 157 + ); 158 + map.insert( 159 + ::jacquard_common::deps::smol_str::SmolStr::new_static("foo"), 160 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 161 + description: Some( 162 + ::jacquard_common::CowStr::new_static( 163 + "A type defined in ns1, referenced cross-namespace by ns2.", 164 + ), 165 + ), 166 + required: Some( 167 + vec![ 168 + ::jacquard_common::deps::smol_str::SmolStr::new_static("name") 169 + ], 170 + ), 171 + properties: { 172 + #[allow(unused_mut)] 173 + let mut map = ::alloc::collections::BTreeMap::new(); 174 + map.insert( 175 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 176 + "name", 177 + ), 178 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 179 + max_length: Some(100usize), 180 + ..Default::default() 181 + }), 182 + ); 183 + map.insert( 184 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 185 + "value", 186 + ), 187 + ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 188 + ..Default::default() 189 + }), 190 + ); 191 + map 192 + }, 193 + ..Default::default() 194 + }), 195 + ); 196 + map 197 + }, 198 + ..Default::default() 199 + } 200 + }
+6
crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns2.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod consumer;
+275
crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns2/consumer.rs
··· 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 + )] 24 + pub 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 + 39 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 40 + for 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 + 67 + pub 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. 100 + pub 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 + 110 + impl<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 + 117 + impl<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 + 128 + impl<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 + 141 + impl<S: jacquard_common::BosStr, St> ConsumerBuilder<S, St> 142 + where 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 + 160 + impl<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 + 179 + impl<S: jacquard_common::BosStr, St> ConsumerBuilder<S, St> 180 + where 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 + 210 + fn 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 + }
+6
crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns3.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod collision;
+482
crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns3/collision.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.ns3.collision 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + /// A locally-defined Foo that shares a name with test.ns1.defs#foo. 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 + )] 24 + pub struct Foo<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 25 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 26 + pub label: core::option::Option<S>, 27 + pub local_id: i64, 28 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 29 + pub extra_data: core::option::Option< 30 + alloc::collections::BTreeMap< 31 + jacquard_common::deps::smol_str::SmolStr, 32 + jacquard_common::types::value::Data<S>, 33 + >, 34 + >, 35 + } 36 + 37 + /// An object with both a local Foo ref and a cross-namespace Foo ref. 38 + 39 + #[derive( 40 + serde::Serialize, 41 + serde::Deserialize, 42 + Debug, 43 + Clone, 44 + PartialEq, 45 + Eq, 46 + jacquard_derive::IntoStatic 47 + )] 48 + 49 + #[serde( 50 + rename_all = "camelCase", 51 + bound(deserialize = "S: serde::Deserialize<'de> + jacquard_common::BosStr") 52 + )] 53 + pub struct Collision<S: jacquard_common::BosStr = jacquard_common::DefaultStr> { 54 + pub external_foo: crate::macro_mode::test_ns1::Foo<S>, 55 + pub local_foo: crate::macro_mode::test_ns3::collision::Foo<S>, 56 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 57 + pub note: core::option::Option<S>, 58 + #[serde(flatten, default, skip_serializing_if = "core::option::Option::is_none")] 59 + pub extra_data: core::option::Option< 60 + alloc::collections::BTreeMap< 61 + jacquard_common::deps::smol_str::SmolStr, 62 + jacquard_common::types::value::Data<S>, 63 + >, 64 + >, 65 + } 66 + 67 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema for Foo<S> { 68 + fn nsid() -> &'static str { 69 + "test.ns3.collision" 70 + } 71 + fn def_name() -> &'static str { 72 + "foo" 73 + } 74 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 75 + lexicon_doc_test_ns3_collision() 76 + } 77 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 78 + if let Some(ref value) = self.label { 79 + #[allow(unused_comparisons)] 80 + if <str>::len(value.as_ref()) > 100usize { 81 + return Err(jacquard_lexicon::validation::ConstraintError::MaxLength { 82 + path: jacquard_lexicon::validation::ValidationPath::from_field( 83 + "label", 84 + ), 85 + max: 100usize, 86 + actual: <str>::len(value.as_ref()), 87 + }); 88 + } 89 + } 90 + Ok(()) 91 + } 92 + } 93 + 94 + impl<S: jacquard_common::BosStr> jacquard_lexicon::schema::LexiconSchema 95 + for Collision<S> { 96 + fn nsid() -> &'static str { 97 + "test.ns3.collision" 98 + } 99 + fn def_name() -> &'static str { 100 + "main" 101 + } 102 + fn lexicon_doc() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 103 + lexicon_doc_test_ns3_collision() 104 + } 105 + fn validate(&self) -> Result<(), jacquard_lexicon::validation::ConstraintError> { 106 + Ok(()) 107 + } 108 + } 109 + 110 + pub mod foo_state { 111 + 112 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 113 + #[allow(unused)] 114 + use ::core::marker::PhantomData; 115 + mod sealed { 116 + pub trait Sealed {} 117 + } 118 + /// State trait tracking which required fields have been set 119 + pub trait State: sealed::Sealed { 120 + type LocalId; 121 + } 122 + /// Empty state - all required fields are unset 123 + pub struct Empty(()); 124 + impl sealed::Sealed for Empty {} 125 + impl State for Empty { 126 + type LocalId = Unset; 127 + } 128 + ///State transition - sets the `local_id` field to Set 129 + pub struct SetLocalId<St: State = Empty>(PhantomData<fn() -> St>); 130 + impl<St: State> sealed::Sealed for SetLocalId<St> {} 131 + impl<St: State> State for SetLocalId<St> { 132 + type LocalId = Set<members::local_id>; 133 + } 134 + /// Marker types for field names 135 + #[allow(non_camel_case_types)] 136 + pub mod members { 137 + ///Marker type for the `local_id` field 138 + pub struct local_id(()); 139 + } 140 + } 141 + 142 + /// Builder for constructing an instance of this type. 143 + pub struct FooBuilder<S: jacquard_common::BosStr, St: foo_state::State> { 144 + _state: ::core::marker::PhantomData<fn() -> St>, 145 + _fields: (core::option::Option<S>, core::option::Option<i64>), 146 + _type: ::core::marker::PhantomData<fn() -> S>, 147 + } 148 + 149 + impl<S: jacquard_common::BosStr> Foo<S> { 150 + /// Create a new builder for this type. 151 + pub fn new() -> FooBuilder<S, foo_state::Empty> { 152 + FooBuilder::new() 153 + } 154 + } 155 + 156 + impl<S: jacquard_common::BosStr> FooBuilder<S, foo_state::Empty> { 157 + /// Create a new builder with all fields unset. 158 + pub fn new() -> Self { 159 + FooBuilder { 160 + _state: ::core::marker::PhantomData, 161 + _fields: (None, None), 162 + _type: ::core::marker::PhantomData, 163 + } 164 + } 165 + } 166 + 167 + impl<S: jacquard_common::BosStr, St: foo_state::State> FooBuilder<S, St> { 168 + /// Set the `label` field (optional) 169 + pub fn label(mut self, value: impl Into<Option<S>>) -> Self { 170 + self._fields.0 = value.into(); 171 + self 172 + } 173 + /// Set the `label` field to an Option value (optional) 174 + pub fn maybe_label(mut self, value: Option<S>) -> Self { 175 + self._fields.0 = value; 176 + self 177 + } 178 + } 179 + 180 + impl<S: jacquard_common::BosStr, St> FooBuilder<S, St> 181 + where 182 + St: foo_state::State, 183 + St::LocalId: foo_state::IsUnset, 184 + { 185 + /// Set the `localId` field (required) 186 + pub fn local_id( 187 + mut self, 188 + value: impl Into<i64>, 189 + ) -> FooBuilder<S, foo_state::SetLocalId<St>> { 190 + self._fields.1 = ::core::option::Option::Some(value.into()); 191 + FooBuilder { 192 + _state: ::core::marker::PhantomData, 193 + _fields: self._fields, 194 + _type: ::core::marker::PhantomData, 195 + } 196 + } 197 + } 198 + 199 + impl<S: jacquard_common::BosStr, St> FooBuilder<S, St> 200 + where 201 + St: foo_state::State, 202 + St::LocalId: foo_state::IsSet, 203 + { 204 + /// Build the final struct. 205 + pub fn build(self) -> Foo<S> { 206 + Foo { 207 + label: self._fields.0, 208 + local_id: self._fields.1.unwrap(), 209 + extra_data: Default::default(), 210 + } 211 + } 212 + /// Build the final struct with custom extra_data. 213 + pub fn build_with_data( 214 + self, 215 + extra_data: alloc::collections::BTreeMap< 216 + jacquard_common::deps::smol_str::SmolStr, 217 + jacquard_common::types::value::Data<S>, 218 + >, 219 + ) -> Foo<S> { 220 + Foo { 221 + label: self._fields.0, 222 + local_id: self._fields.1.unwrap(), 223 + extra_data: Some(extra_data), 224 + } 225 + } 226 + } 227 + 228 + fn lexicon_doc_test_ns3_collision() -> jacquard_lexicon::lexicon::LexiconDoc<'static> { 229 + ::jacquard_lexicon::lexicon::LexiconDoc { 230 + lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 231 + id: ::jacquard_common::CowStr::new_static("test.ns3.collision"), 232 + defs: { 233 + let mut map = ::alloc::collections::BTreeMap::new(); 234 + map.insert( 235 + ::jacquard_common::deps::smol_str::SmolStr::new_static("foo"), 236 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 237 + description: Some( 238 + ::jacquard_common::CowStr::new_static( 239 + "A locally-defined Foo that shares a name with test.ns1.defs#foo.", 240 + ), 241 + ), 242 + required: Some( 243 + vec![ 244 + ::jacquard_common::deps::smol_str::SmolStr::new_static("localId") 245 + ], 246 + ), 247 + properties: { 248 + #[allow(unused_mut)] 249 + let mut map = ::alloc::collections::BTreeMap::new(); 250 + map.insert( 251 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 252 + "label", 253 + ), 254 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 255 + max_length: Some(100usize), 256 + ..Default::default() 257 + }), 258 + ); 259 + map.insert( 260 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 261 + "localId", 262 + ), 263 + ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 264 + ..Default::default() 265 + }), 266 + ); 267 + map 268 + }, 269 + ..Default::default() 270 + }), 271 + ); 272 + map.insert( 273 + ::jacquard_common::deps::smol_str::SmolStr::new_static("main"), 274 + ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 275 + description: Some( 276 + ::jacquard_common::CowStr::new_static( 277 + "An object with both a local Foo ref and a cross-namespace Foo ref.", 278 + ), 279 + ), 280 + required: Some( 281 + vec![ 282 + ::jacquard_common::deps::smol_str::SmolStr::new_static("localFoo"), 283 + ::jacquard_common::deps::smol_str::SmolStr::new_static("externalFoo") 284 + ], 285 + ), 286 + properties: { 287 + #[allow(unused_mut)] 288 + let mut map = ::alloc::collections::BTreeMap::new(); 289 + map.insert( 290 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 291 + "externalFoo", 292 + ), 293 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 294 + r#ref: ::jacquard_common::CowStr::new_static( 295 + "test.ns1.defs#foo", 296 + ), 297 + ..Default::default() 298 + }), 299 + ); 300 + map.insert( 301 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 302 + "localFoo", 303 + ), 304 + ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 305 + r#ref: ::jacquard_common::CowStr::new_static("#foo"), 306 + ..Default::default() 307 + }), 308 + ); 309 + map.insert( 310 + ::jacquard_common::deps::smol_str::SmolStr::new_static( 311 + "note", 312 + ), 313 + ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 314 + ..Default::default() 315 + }), 316 + ); 317 + map 318 + }, 319 + ..Default::default() 320 + }), 321 + ); 322 + map 323 + }, 324 + ..Default::default() 325 + } 326 + } 327 + 328 + pub mod collision_state { 329 + 330 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 331 + #[allow(unused)] 332 + use ::core::marker::PhantomData; 333 + mod sealed { 334 + pub trait Sealed {} 335 + } 336 + /// State trait tracking which required fields have been set 337 + pub trait State: sealed::Sealed { 338 + type LocalFoo; 339 + type ExternalFoo; 340 + } 341 + /// Empty state - all required fields are unset 342 + pub struct Empty(()); 343 + impl sealed::Sealed for Empty {} 344 + impl State for Empty { 345 + type LocalFoo = Unset; 346 + type ExternalFoo = Unset; 347 + } 348 + ///State transition - sets the `local_foo` field to Set 349 + pub struct SetLocalFoo<St: State = Empty>(PhantomData<fn() -> St>); 350 + impl<St: State> sealed::Sealed for SetLocalFoo<St> {} 351 + impl<St: State> State for SetLocalFoo<St> { 352 + type LocalFoo = Set<members::local_foo>; 353 + type ExternalFoo = St::ExternalFoo; 354 + } 355 + ///State transition - sets the `external_foo` field to Set 356 + pub struct SetExternalFoo<St: State = Empty>(PhantomData<fn() -> St>); 357 + impl<St: State> sealed::Sealed for SetExternalFoo<St> {} 358 + impl<St: State> State for SetExternalFoo<St> { 359 + type LocalFoo = St::LocalFoo; 360 + type ExternalFoo = Set<members::external_foo>; 361 + } 362 + /// Marker types for field names 363 + #[allow(non_camel_case_types)] 364 + pub mod members { 365 + ///Marker type for the `local_foo` field 366 + pub struct local_foo(()); 367 + ///Marker type for the `external_foo` field 368 + pub struct external_foo(()); 369 + } 370 + } 371 + 372 + /// Builder for constructing an instance of this type. 373 + pub struct CollisionBuilder<S: jacquard_common::BosStr, St: collision_state::State> { 374 + _state: ::core::marker::PhantomData<fn() -> St>, 375 + _fields: ( 376 + core::option::Option<crate::macro_mode::test_ns1::Foo<S>>, 377 + core::option::Option<crate::macro_mode::test_ns3::collision::Foo<S>>, 378 + core::option::Option<S>, 379 + ), 380 + _type: ::core::marker::PhantomData<fn() -> S>, 381 + } 382 + 383 + impl<S: jacquard_common::BosStr> Collision<S> { 384 + /// Create a new builder for this type. 385 + pub fn new() -> CollisionBuilder<S, collision_state::Empty> { 386 + CollisionBuilder::new() 387 + } 388 + } 389 + 390 + impl<S: jacquard_common::BosStr> CollisionBuilder<S, collision_state::Empty> { 391 + /// Create a new builder with all fields unset. 392 + pub fn new() -> Self { 393 + CollisionBuilder { 394 + _state: ::core::marker::PhantomData, 395 + _fields: (None, None, None), 396 + _type: ::core::marker::PhantomData, 397 + } 398 + } 399 + } 400 + 401 + impl<S: jacquard_common::BosStr, St> CollisionBuilder<S, St> 402 + where 403 + St: collision_state::State, 404 + St::ExternalFoo: collision_state::IsUnset, 405 + { 406 + /// Set the `externalFoo` field (required) 407 + pub fn external_foo( 408 + mut self, 409 + value: impl Into<crate::macro_mode::test_ns1::Foo<S>>, 410 + ) -> CollisionBuilder<S, collision_state::SetExternalFoo<St>> { 411 + self._fields.0 = ::core::option::Option::Some(value.into()); 412 + CollisionBuilder { 413 + _state: ::core::marker::PhantomData, 414 + _fields: self._fields, 415 + _type: ::core::marker::PhantomData, 416 + } 417 + } 418 + } 419 + 420 + impl<S: jacquard_common::BosStr, St> CollisionBuilder<S, St> 421 + where 422 + St: collision_state::State, 423 + St::LocalFoo: collision_state::IsUnset, 424 + { 425 + /// Set the `localFoo` field (required) 426 + pub fn local_foo( 427 + mut self, 428 + value: impl Into<crate::macro_mode::test_ns3::collision::Foo<S>>, 429 + ) -> CollisionBuilder<S, collision_state::SetLocalFoo<St>> { 430 + self._fields.1 = ::core::option::Option::Some(value.into()); 431 + CollisionBuilder { 432 + _state: ::core::marker::PhantomData, 433 + _fields: self._fields, 434 + _type: ::core::marker::PhantomData, 435 + } 436 + } 437 + } 438 + 439 + impl<S: jacquard_common::BosStr, St: collision_state::State> CollisionBuilder<S, St> { 440 + /// Set the `note` field (optional) 441 + pub fn note(mut self, value: impl Into<Option<S>>) -> Self { 442 + self._fields.2 = value.into(); 443 + self 444 + } 445 + /// Set the `note` field to an Option value (optional) 446 + pub fn maybe_note(mut self, value: Option<S>) -> Self { 447 + self._fields.2 = value; 448 + self 449 + } 450 + } 451 + 452 + impl<S: jacquard_common::BosStr, St> CollisionBuilder<S, St> 453 + where 454 + St: collision_state::State, 455 + St::LocalFoo: collision_state::IsSet, 456 + St::ExternalFoo: collision_state::IsSet, 457 + { 458 + /// Build the final struct. 459 + pub fn build(self) -> Collision<S> { 460 + Collision { 461 + external_foo: self._fields.0.unwrap(), 462 + local_foo: self._fields.1.unwrap(), 463 + note: self._fields.2, 464 + extra_data: Default::default(), 465 + } 466 + } 467 + /// Build the final struct with custom extra_data. 468 + pub fn build_with_data( 469 + self, 470 + extra_data: alloc::collections::BTreeMap< 471 + jacquard_common::deps::smol_str::SmolStr, 472 + jacquard_common::types::value::Data<S>, 473 + >, 474 + ) -> Collision<S> { 475 + Collision { 476 + external_foo: self._fields.0.unwrap(), 477 + local_foo: self._fields.1.unwrap(), 478 + note: self._fields.2, 479 + extra_data: Some(extra_data), 480 + } 481 + } 482 + }
+7
crates/jacquard-codegen-tests/src/generated/pretty/app_bsky.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod embed; 7 + pub mod richtext;
+6
crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/embed.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod external;
+868
crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/embed/external.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: app.bsky.embed.external 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::blob::BlobRef; 19 + use jacquard_common::types::string::UriValue; 20 + use jacquard_common::types::value::Data; 21 + use jacquard_derive::IntoStatic; 22 + use jacquard_lexicon::lexicon::LexiconDoc; 23 + use jacquard_lexicon::schema::LexiconSchema; 24 + 25 + #[allow(unused_imports)] 26 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 27 + use serde::{Serialize, Deserialize}; 28 + use crate::pretty::app_bsky::embed::external; 29 + 30 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 31 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 32 + pub struct External<S: BosStr = DefaultStr> { 33 + pub description: S, 34 + #[serde(skip_serializing_if = "Option::is_none")] 35 + pub thumb: Option<BlobRef<S>>, 36 + pub title: S, 37 + pub uri: UriValue<S>, 38 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 39 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 40 + } 41 + 42 + /// A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post). 43 + 44 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 45 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 46 + pub struct ExternalRecord<S: BosStr = DefaultStr> { 47 + pub external: external::External<S>, 48 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 49 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 50 + } 51 + 52 + 53 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 54 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 55 + pub struct View<S: BosStr = DefaultStr> { 56 + pub external: external::ViewExternal<S>, 57 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 58 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 59 + } 60 + 61 + 62 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 63 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 64 + pub struct ViewExternal<S: BosStr = DefaultStr> { 65 + pub description: S, 66 + #[serde(skip_serializing_if = "Option::is_none")] 67 + pub thumb: Option<UriValue<S>>, 68 + pub title: S, 69 + pub uri: UriValue<S>, 70 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 71 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 72 + } 73 + 74 + impl<S: BosStr> LexiconSchema for External<S> { 75 + fn nsid() -> &'static str { 76 + "app.bsky.embed.external" 77 + } 78 + fn def_name() -> &'static str { 79 + "external" 80 + } 81 + fn lexicon_doc() -> LexiconDoc<'static> { 82 + lexicon_doc_app_bsky_embed_external() 83 + } 84 + fn validate(&self) -> Result<(), ConstraintError> { 85 + if let Some(ref value) = self.thumb { 86 + { 87 + let size = value.blob().size; 88 + if size > 1000000usize { 89 + return Err(ConstraintError::BlobTooLarge { 90 + path: ValidationPath::from_field("thumb"), 91 + max: 1000000usize, 92 + actual: size, 93 + }); 94 + } 95 + } 96 + } 97 + if let Some(ref value) = self.thumb { 98 + { 99 + let mime = value.blob().mime_type.as_str(); 100 + let accepted: &[&str] = &["image/*"]; 101 + let matched = accepted 102 + .iter() 103 + .any(|pattern| { 104 + if *pattern == "*/*" { 105 + true 106 + } else if pattern.ends_with("/*") { 107 + let prefix = &pattern[..pattern.len() - 2]; 108 + mime.starts_with(prefix) 109 + && mime.as_bytes().get(prefix.len()) == Some(&b'/') 110 + } else { 111 + mime == *pattern 112 + } 113 + }); 114 + if !matched { 115 + return Err(ConstraintError::BlobMimeTypeNotAccepted { 116 + path: ValidationPath::from_field("thumb"), 117 + accepted: vec!["image/*".to_string()], 118 + actual: mime.to_string(), 119 + }); 120 + } 121 + } 122 + } 123 + Ok(()) 124 + } 125 + } 126 + 127 + impl<S: BosStr> LexiconSchema for ExternalRecord<S> { 128 + fn nsid() -> &'static str { 129 + "app.bsky.embed.external" 130 + } 131 + fn def_name() -> &'static str { 132 + "main" 133 + } 134 + fn lexicon_doc() -> LexiconDoc<'static> { 135 + lexicon_doc_app_bsky_embed_external() 136 + } 137 + fn validate(&self) -> Result<(), ConstraintError> { 138 + Ok(()) 139 + } 140 + } 141 + 142 + impl<S: BosStr> LexiconSchema for View<S> { 143 + fn nsid() -> &'static str { 144 + "app.bsky.embed.external" 145 + } 146 + fn def_name() -> &'static str { 147 + "view" 148 + } 149 + fn lexicon_doc() -> LexiconDoc<'static> { 150 + lexicon_doc_app_bsky_embed_external() 151 + } 152 + fn validate(&self) -> Result<(), ConstraintError> { 153 + Ok(()) 154 + } 155 + } 156 + 157 + impl<S: BosStr> LexiconSchema for ViewExternal<S> { 158 + fn nsid() -> &'static str { 159 + "app.bsky.embed.external" 160 + } 161 + fn def_name() -> &'static str { 162 + "viewExternal" 163 + } 164 + fn lexicon_doc() -> LexiconDoc<'static> { 165 + lexicon_doc_app_bsky_embed_external() 166 + } 167 + fn validate(&self) -> Result<(), ConstraintError> { 168 + Ok(()) 169 + } 170 + } 171 + 172 + pub mod external_state { 173 + 174 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 175 + #[allow(unused)] 176 + use ::core::marker::PhantomData; 177 + mod sealed { 178 + pub trait Sealed {} 179 + } 180 + /// State trait tracking which required fields have been set 181 + pub trait State: sealed::Sealed { 182 + type Title; 183 + type Description; 184 + type Uri; 185 + } 186 + /// Empty state - all required fields are unset 187 + pub struct Empty(()); 188 + impl sealed::Sealed for Empty {} 189 + impl State for Empty { 190 + type Title = Unset; 191 + type Description = Unset; 192 + type Uri = Unset; 193 + } 194 + ///State transition - sets the `title` field to Set 195 + pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>); 196 + impl<St: State> sealed::Sealed for SetTitle<St> {} 197 + impl<St: State> State for SetTitle<St> { 198 + type Title = Set<members::title>; 199 + type Description = St::Description; 200 + type Uri = St::Uri; 201 + } 202 + ///State transition - sets the `description` field to Set 203 + pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>); 204 + impl<St: State> sealed::Sealed for SetDescription<St> {} 205 + impl<St: State> State for SetDescription<St> { 206 + type Title = St::Title; 207 + type Description = Set<members::description>; 208 + type Uri = St::Uri; 209 + } 210 + ///State transition - sets the `uri` field to Set 211 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 212 + impl<St: State> sealed::Sealed for SetUri<St> {} 213 + impl<St: State> State for SetUri<St> { 214 + type Title = St::Title; 215 + type Description = St::Description; 216 + type Uri = Set<members::uri>; 217 + } 218 + /// Marker types for field names 219 + #[allow(non_camel_case_types)] 220 + pub mod members { 221 + ///Marker type for the `title` field 222 + pub struct title(()); 223 + ///Marker type for the `description` field 224 + pub struct description(()); 225 + ///Marker type for the `uri` field 226 + pub struct uri(()); 227 + } 228 + } 229 + 230 + /// Builder for constructing an instance of this type. 231 + pub struct ExternalBuilder<S: BosStr, St: external_state::State> { 232 + _state: PhantomData<fn() -> St>, 233 + _fields: (Option<S>, Option<BlobRef<S>>, Option<S>, Option<UriValue<S>>), 234 + _type: PhantomData<fn() -> S>, 235 + } 236 + 237 + impl<S: BosStr> External<S> { 238 + /// Create a new builder for this type. 239 + pub fn new() -> ExternalBuilder<S, external_state::Empty> { 240 + ExternalBuilder::new() 241 + } 242 + } 243 + 244 + impl<S: BosStr> ExternalBuilder<S, external_state::Empty> { 245 + /// Create a new builder with all fields unset. 246 + pub fn new() -> Self { 247 + ExternalBuilder { 248 + _state: PhantomData, 249 + _fields: (None, None, None, None), 250 + _type: PhantomData, 251 + } 252 + } 253 + } 254 + 255 + impl<S: BosStr, St> ExternalBuilder<S, St> 256 + where 257 + St: external_state::State, 258 + St::Description: external_state::IsUnset, 259 + { 260 + /// Set the `description` field (required) 261 + pub fn description( 262 + mut self, 263 + value: impl Into<S>, 264 + ) -> ExternalBuilder<S, external_state::SetDescription<St>> { 265 + self._fields.0 = Option::Some(value.into()); 266 + ExternalBuilder { 267 + _state: PhantomData, 268 + _fields: self._fields, 269 + _type: PhantomData, 270 + } 271 + } 272 + } 273 + 274 + impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> { 275 + /// Set the `thumb` field (optional) 276 + pub fn thumb(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self { 277 + self._fields.1 = value.into(); 278 + self 279 + } 280 + /// Set the `thumb` field to an Option value (optional) 281 + pub fn maybe_thumb(mut self, value: Option<BlobRef<S>>) -> Self { 282 + self._fields.1 = value; 283 + self 284 + } 285 + } 286 + 287 + impl<S: BosStr, St> ExternalBuilder<S, St> 288 + where 289 + St: external_state::State, 290 + St::Title: external_state::IsUnset, 291 + { 292 + /// Set the `title` field (required) 293 + pub fn title( 294 + mut self, 295 + value: impl Into<S>, 296 + ) -> ExternalBuilder<S, external_state::SetTitle<St>> { 297 + self._fields.2 = Option::Some(value.into()); 298 + ExternalBuilder { 299 + _state: PhantomData, 300 + _fields: self._fields, 301 + _type: PhantomData, 302 + } 303 + } 304 + } 305 + 306 + impl<S: BosStr, St> ExternalBuilder<S, St> 307 + where 308 + St: external_state::State, 309 + St::Uri: external_state::IsUnset, 310 + { 311 + /// Set the `uri` field (required) 312 + pub fn uri( 313 + mut self, 314 + value: impl Into<UriValue<S>>, 315 + ) -> ExternalBuilder<S, external_state::SetUri<St>> { 316 + self._fields.3 = Option::Some(value.into()); 317 + ExternalBuilder { 318 + _state: PhantomData, 319 + _fields: self._fields, 320 + _type: PhantomData, 321 + } 322 + } 323 + } 324 + 325 + impl<S: BosStr, St> ExternalBuilder<S, St> 326 + where 327 + St: external_state::State, 328 + St::Title: external_state::IsSet, 329 + St::Description: external_state::IsSet, 330 + St::Uri: external_state::IsSet, 331 + { 332 + /// Build the final struct. 333 + pub fn build(self) -> External<S> { 334 + External { 335 + description: self._fields.0.unwrap(), 336 + thumb: self._fields.1, 337 + title: self._fields.2.unwrap(), 338 + uri: self._fields.3.unwrap(), 339 + extra_data: Default::default(), 340 + } 341 + } 342 + /// Build the final struct with custom extra_data. 343 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> External<S> { 344 + External { 345 + description: self._fields.0.unwrap(), 346 + thumb: self._fields.1, 347 + title: self._fields.2.unwrap(), 348 + uri: self._fields.3.unwrap(), 349 + extra_data: Some(extra_data), 350 + } 351 + } 352 + } 353 + 354 + fn lexicon_doc_app_bsky_embed_external() -> LexiconDoc<'static> { 355 + #[allow(unused_imports)] 356 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 357 + use jacquard_lexicon::lexicon::*; 358 + use alloc::collections::BTreeMap; 359 + LexiconDoc { 360 + lexicon: Lexicon::Lexicon1, 361 + id: CowStr::new_static("app.bsky.embed.external"), 362 + defs: { 363 + let mut map = BTreeMap::new(); 364 + map.insert( 365 + SmolStr::new_static("external"), 366 + LexUserType::Object(LexObject { 367 + required: Some( 368 + vec![ 369 + SmolStr::new_static("uri"), SmolStr::new_static("title"), 370 + SmolStr::new_static("description") 371 + ], 372 + ), 373 + properties: { 374 + #[allow(unused_mut)] 375 + let mut map = BTreeMap::new(); 376 + map.insert( 377 + SmolStr::new_static("description"), 378 + LexObjectProperty::String(LexString { ..Default::default() }), 379 + ); 380 + map.insert( 381 + SmolStr::new_static("thumb"), 382 + LexObjectProperty::Blob(LexBlob { ..Default::default() }), 383 + ); 384 + map.insert( 385 + SmolStr::new_static("title"), 386 + LexObjectProperty::String(LexString { ..Default::default() }), 387 + ); 388 + map.insert( 389 + SmolStr::new_static("uri"), 390 + LexObjectProperty::String(LexString { 391 + format: Some(LexStringFormat::Uri), 392 + ..Default::default() 393 + }), 394 + ); 395 + map 396 + }, 397 + ..Default::default() 398 + }), 399 + ); 400 + map.insert( 401 + SmolStr::new_static("main"), 402 + LexUserType::Object(LexObject { 403 + description: Some( 404 + CowStr::new_static( 405 + "A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post).", 406 + ), 407 + ), 408 + required: Some(vec![SmolStr::new_static("external")]), 409 + properties: { 410 + #[allow(unused_mut)] 411 + let mut map = BTreeMap::new(); 412 + map.insert( 413 + SmolStr::new_static("external"), 414 + LexObjectProperty::Ref(LexRef { 415 + r#ref: CowStr::new_static("#external"), 416 + ..Default::default() 417 + }), 418 + ); 419 + map 420 + }, 421 + ..Default::default() 422 + }), 423 + ); 424 + map.insert( 425 + SmolStr::new_static("view"), 426 + LexUserType::Object(LexObject { 427 + required: Some(vec![SmolStr::new_static("external")]), 428 + properties: { 429 + #[allow(unused_mut)] 430 + let mut map = BTreeMap::new(); 431 + map.insert( 432 + SmolStr::new_static("external"), 433 + LexObjectProperty::Ref(LexRef { 434 + r#ref: CowStr::new_static("#viewExternal"), 435 + ..Default::default() 436 + }), 437 + ); 438 + map 439 + }, 440 + ..Default::default() 441 + }), 442 + ); 443 + map.insert( 444 + SmolStr::new_static("viewExternal"), 445 + LexUserType::Object(LexObject { 446 + required: Some( 447 + vec![ 448 + SmolStr::new_static("uri"), SmolStr::new_static("title"), 449 + SmolStr::new_static("description") 450 + ], 451 + ), 452 + properties: { 453 + #[allow(unused_mut)] 454 + let mut map = BTreeMap::new(); 455 + map.insert( 456 + SmolStr::new_static("description"), 457 + LexObjectProperty::String(LexString { ..Default::default() }), 458 + ); 459 + map.insert( 460 + SmolStr::new_static("thumb"), 461 + LexObjectProperty::String(LexString { 462 + format: Some(LexStringFormat::Uri), 463 + ..Default::default() 464 + }), 465 + ); 466 + map.insert( 467 + SmolStr::new_static("title"), 468 + LexObjectProperty::String(LexString { ..Default::default() }), 469 + ); 470 + map.insert( 471 + SmolStr::new_static("uri"), 472 + LexObjectProperty::String(LexString { 473 + format: Some(LexStringFormat::Uri), 474 + ..Default::default() 475 + }), 476 + ); 477 + map 478 + }, 479 + ..Default::default() 480 + }), 481 + ); 482 + map 483 + }, 484 + ..Default::default() 485 + } 486 + } 487 + 488 + pub mod external_record_state { 489 + 490 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 491 + #[allow(unused)] 492 + use ::core::marker::PhantomData; 493 + mod sealed { 494 + pub trait Sealed {} 495 + } 496 + /// State trait tracking which required fields have been set 497 + pub trait State: sealed::Sealed { 498 + type External; 499 + } 500 + /// Empty state - all required fields are unset 501 + pub struct Empty(()); 502 + impl sealed::Sealed for Empty {} 503 + impl State for Empty { 504 + type External = Unset; 505 + } 506 + ///State transition - sets the `external` field to Set 507 + pub struct SetExternal<St: State = Empty>(PhantomData<fn() -> St>); 508 + impl<St: State> sealed::Sealed for SetExternal<St> {} 509 + impl<St: State> State for SetExternal<St> { 510 + type External = Set<members::external>; 511 + } 512 + /// Marker types for field names 513 + #[allow(non_camel_case_types)] 514 + pub mod members { 515 + ///Marker type for the `external` field 516 + pub struct external(()); 517 + } 518 + } 519 + 520 + /// Builder for constructing an instance of this type. 521 + pub struct ExternalRecordBuilder<S: BosStr, St: external_record_state::State> { 522 + _state: PhantomData<fn() -> St>, 523 + _fields: (Option<external::External<S>>,), 524 + _type: PhantomData<fn() -> S>, 525 + } 526 + 527 + impl<S: BosStr> ExternalRecord<S> { 528 + /// Create a new builder for this type. 529 + pub fn new() -> ExternalRecordBuilder<S, external_record_state::Empty> { 530 + ExternalRecordBuilder::new() 531 + } 532 + } 533 + 534 + impl<S: BosStr> ExternalRecordBuilder<S, external_record_state::Empty> { 535 + /// Create a new builder with all fields unset. 536 + pub fn new() -> Self { 537 + ExternalRecordBuilder { 538 + _state: PhantomData, 539 + _fields: (None,), 540 + _type: PhantomData, 541 + } 542 + } 543 + } 544 + 545 + impl<S: BosStr, St> ExternalRecordBuilder<S, St> 546 + where 547 + St: external_record_state::State, 548 + St::External: external_record_state::IsUnset, 549 + { 550 + /// Set the `external` field (required) 551 + pub fn external( 552 + mut self, 553 + value: impl Into<external::External<S>>, 554 + ) -> ExternalRecordBuilder<S, external_record_state::SetExternal<St>> { 555 + self._fields.0 = Option::Some(value.into()); 556 + ExternalRecordBuilder { 557 + _state: PhantomData, 558 + _fields: self._fields, 559 + _type: PhantomData, 560 + } 561 + } 562 + } 563 + 564 + impl<S: BosStr, St> ExternalRecordBuilder<S, St> 565 + where 566 + St: external_record_state::State, 567 + St::External: external_record_state::IsSet, 568 + { 569 + /// Build the final struct. 570 + pub fn build(self) -> ExternalRecord<S> { 571 + ExternalRecord { 572 + external: self._fields.0.unwrap(), 573 + extra_data: Default::default(), 574 + } 575 + } 576 + /// Build the final struct with custom extra_data. 577 + pub fn build_with_data( 578 + self, 579 + extra_data: BTreeMap<SmolStr, Data<S>>, 580 + ) -> ExternalRecord<S> { 581 + ExternalRecord { 582 + external: self._fields.0.unwrap(), 583 + extra_data: Some(extra_data), 584 + } 585 + } 586 + } 587 + 588 + pub mod view_state { 589 + 590 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 591 + #[allow(unused)] 592 + use ::core::marker::PhantomData; 593 + mod sealed { 594 + pub trait Sealed {} 595 + } 596 + /// State trait tracking which required fields have been set 597 + pub trait State: sealed::Sealed { 598 + type External; 599 + } 600 + /// Empty state - all required fields are unset 601 + pub struct Empty(()); 602 + impl sealed::Sealed for Empty {} 603 + impl State for Empty { 604 + type External = Unset; 605 + } 606 + ///State transition - sets the `external` field to Set 607 + pub struct SetExternal<St: State = Empty>(PhantomData<fn() -> St>); 608 + impl<St: State> sealed::Sealed for SetExternal<St> {} 609 + impl<St: State> State for SetExternal<St> { 610 + type External = Set<members::external>; 611 + } 612 + /// Marker types for field names 613 + #[allow(non_camel_case_types)] 614 + pub mod members { 615 + ///Marker type for the `external` field 616 + pub struct external(()); 617 + } 618 + } 619 + 620 + /// Builder for constructing an instance of this type. 621 + pub struct ViewBuilder<S: BosStr, St: view_state::State> { 622 + _state: PhantomData<fn() -> St>, 623 + _fields: (Option<external::ViewExternal<S>>,), 624 + _type: PhantomData<fn() -> S>, 625 + } 626 + 627 + impl<S: BosStr> View<S> { 628 + /// Create a new builder for this type. 629 + pub fn new() -> ViewBuilder<S, view_state::Empty> { 630 + ViewBuilder::new() 631 + } 632 + } 633 + 634 + impl<S: BosStr> ViewBuilder<S, view_state::Empty> { 635 + /// Create a new builder with all fields unset. 636 + pub fn new() -> Self { 637 + ViewBuilder { 638 + _state: PhantomData, 639 + _fields: (None,), 640 + _type: PhantomData, 641 + } 642 + } 643 + } 644 + 645 + impl<S: BosStr, St> ViewBuilder<S, St> 646 + where 647 + St: view_state::State, 648 + St::External: view_state::IsUnset, 649 + { 650 + /// Set the `external` field (required) 651 + pub fn external( 652 + mut self, 653 + value: impl Into<external::ViewExternal<S>>, 654 + ) -> ViewBuilder<S, view_state::SetExternal<St>> { 655 + self._fields.0 = Option::Some(value.into()); 656 + ViewBuilder { 657 + _state: PhantomData, 658 + _fields: self._fields, 659 + _type: PhantomData, 660 + } 661 + } 662 + } 663 + 664 + impl<S: BosStr, St> ViewBuilder<S, St> 665 + where 666 + St: view_state::State, 667 + St::External: view_state::IsSet, 668 + { 669 + /// Build the final struct. 670 + pub fn build(self) -> View<S> { 671 + View { 672 + external: self._fields.0.unwrap(), 673 + extra_data: Default::default(), 674 + } 675 + } 676 + /// Build the final struct with custom extra_data. 677 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> View<S> { 678 + View { 679 + external: self._fields.0.unwrap(), 680 + extra_data: Some(extra_data), 681 + } 682 + } 683 + } 684 + 685 + pub mod view_external_state { 686 + 687 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 688 + #[allow(unused)] 689 + use ::core::marker::PhantomData; 690 + mod sealed { 691 + pub trait Sealed {} 692 + } 693 + /// State trait tracking which required fields have been set 694 + pub trait State: sealed::Sealed { 695 + type Uri; 696 + type Title; 697 + type Description; 698 + } 699 + /// Empty state - all required fields are unset 700 + pub struct Empty(()); 701 + impl sealed::Sealed for Empty {} 702 + impl State for Empty { 703 + type Uri = Unset; 704 + type Title = Unset; 705 + type Description = Unset; 706 + } 707 + ///State transition - sets the `uri` field to Set 708 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 709 + impl<St: State> sealed::Sealed for SetUri<St> {} 710 + impl<St: State> State for SetUri<St> { 711 + type Uri = Set<members::uri>; 712 + type Title = St::Title; 713 + type Description = St::Description; 714 + } 715 + ///State transition - sets the `title` field to Set 716 + pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>); 717 + impl<St: State> sealed::Sealed for SetTitle<St> {} 718 + impl<St: State> State for SetTitle<St> { 719 + type Uri = St::Uri; 720 + type Title = Set<members::title>; 721 + type Description = St::Description; 722 + } 723 + ///State transition - sets the `description` field to Set 724 + pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>); 725 + impl<St: State> sealed::Sealed for SetDescription<St> {} 726 + impl<St: State> State for SetDescription<St> { 727 + type Uri = St::Uri; 728 + type Title = St::Title; 729 + type Description = Set<members::description>; 730 + } 731 + /// Marker types for field names 732 + #[allow(non_camel_case_types)] 733 + pub mod members { 734 + ///Marker type for the `uri` field 735 + pub struct uri(()); 736 + ///Marker type for the `title` field 737 + pub struct title(()); 738 + ///Marker type for the `description` field 739 + pub struct description(()); 740 + } 741 + } 742 + 743 + /// Builder for constructing an instance of this type. 744 + pub struct ViewExternalBuilder<S: BosStr, St: view_external_state::State> { 745 + _state: PhantomData<fn() -> St>, 746 + _fields: (Option<S>, Option<UriValue<S>>, Option<S>, Option<UriValue<S>>), 747 + _type: PhantomData<fn() -> S>, 748 + } 749 + 750 + impl<S: BosStr> ViewExternal<S> { 751 + /// Create a new builder for this type. 752 + pub fn new() -> ViewExternalBuilder<S, view_external_state::Empty> { 753 + ViewExternalBuilder::new() 754 + } 755 + } 756 + 757 + impl<S: BosStr> ViewExternalBuilder<S, view_external_state::Empty> { 758 + /// Create a new builder with all fields unset. 759 + pub fn new() -> Self { 760 + ViewExternalBuilder { 761 + _state: PhantomData, 762 + _fields: (None, None, None, None), 763 + _type: PhantomData, 764 + } 765 + } 766 + } 767 + 768 + impl<S: BosStr, St> ViewExternalBuilder<S, St> 769 + where 770 + St: view_external_state::State, 771 + St::Description: view_external_state::IsUnset, 772 + { 773 + /// Set the `description` field (required) 774 + pub fn description( 775 + mut self, 776 + value: impl Into<S>, 777 + ) -> ViewExternalBuilder<S, view_external_state::SetDescription<St>> { 778 + self._fields.0 = Option::Some(value.into()); 779 + ViewExternalBuilder { 780 + _state: PhantomData, 781 + _fields: self._fields, 782 + _type: PhantomData, 783 + } 784 + } 785 + } 786 + 787 + impl<S: BosStr, St: view_external_state::State> ViewExternalBuilder<S, St> { 788 + /// Set the `thumb` field (optional) 789 + pub fn thumb(mut self, value: impl Into<Option<UriValue<S>>>) -> Self { 790 + self._fields.1 = value.into(); 791 + self 792 + } 793 + /// Set the `thumb` field to an Option value (optional) 794 + pub fn maybe_thumb(mut self, value: Option<UriValue<S>>) -> Self { 795 + self._fields.1 = value; 796 + self 797 + } 798 + } 799 + 800 + impl<S: BosStr, St> ViewExternalBuilder<S, St> 801 + where 802 + St: view_external_state::State, 803 + St::Title: view_external_state::IsUnset, 804 + { 805 + /// Set the `title` field (required) 806 + pub fn title( 807 + mut self, 808 + value: impl Into<S>, 809 + ) -> ViewExternalBuilder<S, view_external_state::SetTitle<St>> { 810 + self._fields.2 = Option::Some(value.into()); 811 + ViewExternalBuilder { 812 + _state: PhantomData, 813 + _fields: self._fields, 814 + _type: PhantomData, 815 + } 816 + } 817 + } 818 + 819 + impl<S: BosStr, St> ViewExternalBuilder<S, St> 820 + where 821 + St: view_external_state::State, 822 + St::Uri: view_external_state::IsUnset, 823 + { 824 + /// Set the `uri` field (required) 825 + pub fn uri( 826 + mut self, 827 + value: impl Into<UriValue<S>>, 828 + ) -> ViewExternalBuilder<S, view_external_state::SetUri<St>> { 829 + self._fields.3 = Option::Some(value.into()); 830 + ViewExternalBuilder { 831 + _state: PhantomData, 832 + _fields: self._fields, 833 + _type: PhantomData, 834 + } 835 + } 836 + } 837 + 838 + impl<S: BosStr, St> ViewExternalBuilder<S, St> 839 + where 840 + St: view_external_state::State, 841 + St::Uri: view_external_state::IsSet, 842 + St::Title: view_external_state::IsSet, 843 + St::Description: view_external_state::IsSet, 844 + { 845 + /// Build the final struct. 846 + pub fn build(self) -> ViewExternal<S> { 847 + ViewExternal { 848 + description: self._fields.0.unwrap(), 849 + thumb: self._fields.1, 850 + title: self._fields.2.unwrap(), 851 + uri: self._fields.3.unwrap(), 852 + extra_data: Default::default(), 853 + } 854 + } 855 + /// Build the final struct with custom extra_data. 856 + pub fn build_with_data( 857 + self, 858 + extra_data: BTreeMap<SmolStr, Data<S>>, 859 + ) -> ViewExternal<S> { 860 + ViewExternal { 861 + description: self._fields.0.unwrap(), 862 + thumb: self._fields.1, 863 + title: self._fields.2.unwrap(), 864 + uri: self._fields.3.unwrap(), 865 + extra_data: Some(extra_data), 866 + } 867 + } 868 + }
+6
crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/richtext.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod facet;
+835
crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/richtext/facet.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: app.bsky.richtext.facet 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::string::{Did, UriValue}; 19 + use jacquard_common::types::value::Data; 20 + use jacquard_derive::{IntoStatic, open_union}; 21 + use jacquard_lexicon::lexicon::LexiconDoc; 22 + use jacquard_lexicon::schema::LexiconSchema; 23 + 24 + #[allow(unused_imports)] 25 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 26 + use serde::{Serialize, Deserialize}; 27 + use crate::pretty::app_bsky::richtext::facet; 28 + /// Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets. 29 + 30 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 31 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 32 + pub struct ByteSlice<S: BosStr = DefaultStr> { 33 + pub byte_end: i64, 34 + pub byte_start: i64, 35 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 36 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 37 + } 38 + 39 + /// Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL. 40 + 41 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 42 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 43 + pub struct Link<S: BosStr = DefaultStr> { 44 + pub uri: UriValue<S>, 45 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 46 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 47 + } 48 + 49 + /// Annotation of a sub-string within rich text. 50 + 51 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 52 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 53 + pub struct Facet<S: BosStr = DefaultStr> { 54 + pub features: Vec<FacetFeaturesItem<S>>, 55 + pub index: facet::ByteSlice<S>, 56 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 57 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 58 + } 59 + 60 + 61 + #[open_union] 62 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 63 + #[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 64 + pub enum FacetFeaturesItem<S: BosStr = DefaultStr> { 65 + #[serde(rename = "app.bsky.richtext.facet#mention")] 66 + Mention(Box<facet::Mention<S>>), 67 + #[serde(rename = "app.bsky.richtext.facet#link")] 68 + Link(Box<facet::Link<S>>), 69 + #[serde(rename = "app.bsky.richtext.facet#tag")] 70 + Tag(Box<facet::Tag<S>>), 71 + } 72 + 73 + /// Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID. 74 + 75 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 76 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 77 + pub struct Mention<S: BosStr = DefaultStr> { 78 + pub did: Did<S>, 79 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 80 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 81 + } 82 + 83 + /// Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags'). 84 + 85 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 86 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 87 + pub struct Tag<S: BosStr = DefaultStr> { 88 + pub tag: S, 89 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 90 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 91 + } 92 + 93 + impl<S: BosStr> LexiconSchema for ByteSlice<S> { 94 + fn nsid() -> &'static str { 95 + "app.bsky.richtext.facet" 96 + } 97 + fn def_name() -> &'static str { 98 + "byteSlice" 99 + } 100 + fn lexicon_doc() -> LexiconDoc<'static> { 101 + lexicon_doc_app_bsky_richtext_facet() 102 + } 103 + fn validate(&self) -> Result<(), ConstraintError> { 104 + { 105 + let value = &self.byte_end; 106 + if *value < 0i64 { 107 + return Err(ConstraintError::Minimum { 108 + path: ValidationPath::from_field("byte_end"), 109 + min: 0i64, 110 + actual: *value, 111 + }); 112 + } 113 + } 114 + { 115 + let value = &self.byte_start; 116 + if *value < 0i64 { 117 + return Err(ConstraintError::Minimum { 118 + path: ValidationPath::from_field("byte_start"), 119 + min: 0i64, 120 + actual: *value, 121 + }); 122 + } 123 + } 124 + Ok(()) 125 + } 126 + } 127 + 128 + impl<S: BosStr> LexiconSchema for Link<S> { 129 + fn nsid() -> &'static str { 130 + "app.bsky.richtext.facet" 131 + } 132 + fn def_name() -> &'static str { 133 + "link" 134 + } 135 + fn lexicon_doc() -> LexiconDoc<'static> { 136 + lexicon_doc_app_bsky_richtext_facet() 137 + } 138 + fn validate(&self) -> Result<(), ConstraintError> { 139 + Ok(()) 140 + } 141 + } 142 + 143 + impl<S: BosStr> LexiconSchema for Facet<S> { 144 + fn nsid() -> &'static str { 145 + "app.bsky.richtext.facet" 146 + } 147 + fn def_name() -> &'static str { 148 + "main" 149 + } 150 + fn lexicon_doc() -> LexiconDoc<'static> { 151 + lexicon_doc_app_bsky_richtext_facet() 152 + } 153 + fn validate(&self) -> Result<(), ConstraintError> { 154 + Ok(()) 155 + } 156 + } 157 + 158 + impl<S: BosStr> LexiconSchema for Mention<S> { 159 + fn nsid() -> &'static str { 160 + "app.bsky.richtext.facet" 161 + } 162 + fn def_name() -> &'static str { 163 + "mention" 164 + } 165 + fn lexicon_doc() -> LexiconDoc<'static> { 166 + lexicon_doc_app_bsky_richtext_facet() 167 + } 168 + fn validate(&self) -> Result<(), ConstraintError> { 169 + Ok(()) 170 + } 171 + } 172 + 173 + impl<S: BosStr> LexiconSchema for Tag<S> { 174 + fn nsid() -> &'static str { 175 + "app.bsky.richtext.facet" 176 + } 177 + fn def_name() -> &'static str { 178 + "tag" 179 + } 180 + fn lexicon_doc() -> LexiconDoc<'static> { 181 + lexicon_doc_app_bsky_richtext_facet() 182 + } 183 + fn validate(&self) -> Result<(), ConstraintError> { 184 + { 185 + let value = &self.tag; 186 + #[allow(unused_comparisons)] 187 + if <str>::len(value.as_ref()) > 640usize { 188 + return Err(ConstraintError::MaxLength { 189 + path: ValidationPath::from_field("tag"), 190 + max: 640usize, 191 + actual: <str>::len(value.as_ref()), 192 + }); 193 + } 194 + } 195 + { 196 + let value = &self.tag; 197 + { 198 + let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); 199 + if count > 64usize { 200 + return Err(ConstraintError::MaxGraphemes { 201 + path: ValidationPath::from_field("tag"), 202 + max: 64usize, 203 + actual: count, 204 + }); 205 + } 206 + } 207 + } 208 + Ok(()) 209 + } 210 + } 211 + 212 + pub mod byte_slice_state { 213 + 214 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 215 + #[allow(unused)] 216 + use ::core::marker::PhantomData; 217 + mod sealed { 218 + pub trait Sealed {} 219 + } 220 + /// State trait tracking which required fields have been set 221 + pub trait State: sealed::Sealed { 222 + type ByteEnd; 223 + type ByteStart; 224 + } 225 + /// Empty state - all required fields are unset 226 + pub struct Empty(()); 227 + impl sealed::Sealed for Empty {} 228 + impl State for Empty { 229 + type ByteEnd = Unset; 230 + type ByteStart = Unset; 231 + } 232 + ///State transition - sets the `byte_end` field to Set 233 + pub struct SetByteEnd<St: State = Empty>(PhantomData<fn() -> St>); 234 + impl<St: State> sealed::Sealed for SetByteEnd<St> {} 235 + impl<St: State> State for SetByteEnd<St> { 236 + type ByteEnd = Set<members::byte_end>; 237 + type ByteStart = St::ByteStart; 238 + } 239 + ///State transition - sets the `byte_start` field to Set 240 + pub struct SetByteStart<St: State = Empty>(PhantomData<fn() -> St>); 241 + impl<St: State> sealed::Sealed for SetByteStart<St> {} 242 + impl<St: State> State for SetByteStart<St> { 243 + type ByteEnd = St::ByteEnd; 244 + type ByteStart = Set<members::byte_start>; 245 + } 246 + /// Marker types for field names 247 + #[allow(non_camel_case_types)] 248 + pub mod members { 249 + ///Marker type for the `byte_end` field 250 + pub struct byte_end(()); 251 + ///Marker type for the `byte_start` field 252 + pub struct byte_start(()); 253 + } 254 + } 255 + 256 + /// Builder for constructing an instance of this type. 257 + pub struct ByteSliceBuilder<S: BosStr, St: byte_slice_state::State> { 258 + _state: PhantomData<fn() -> St>, 259 + _fields: (Option<i64>, Option<i64>), 260 + _type: PhantomData<fn() -> S>, 261 + } 262 + 263 + impl<S: BosStr> ByteSlice<S> { 264 + /// Create a new builder for this type. 265 + pub fn new() -> ByteSliceBuilder<S, byte_slice_state::Empty> { 266 + ByteSliceBuilder::new() 267 + } 268 + } 269 + 270 + impl<S: BosStr> ByteSliceBuilder<S, byte_slice_state::Empty> { 271 + /// Create a new builder with all fields unset. 272 + pub fn new() -> Self { 273 + ByteSliceBuilder { 274 + _state: PhantomData, 275 + _fields: (None, None), 276 + _type: PhantomData, 277 + } 278 + } 279 + } 280 + 281 + impl<S: BosStr, St> ByteSliceBuilder<S, St> 282 + where 283 + St: byte_slice_state::State, 284 + St::ByteEnd: byte_slice_state::IsUnset, 285 + { 286 + /// Set the `byteEnd` field (required) 287 + pub fn byte_end( 288 + mut self, 289 + value: impl Into<i64>, 290 + ) -> ByteSliceBuilder<S, byte_slice_state::SetByteEnd<St>> { 291 + self._fields.0 = Option::Some(value.into()); 292 + ByteSliceBuilder { 293 + _state: PhantomData, 294 + _fields: self._fields, 295 + _type: PhantomData, 296 + } 297 + } 298 + } 299 + 300 + impl<S: BosStr, St> ByteSliceBuilder<S, St> 301 + where 302 + St: byte_slice_state::State, 303 + St::ByteStart: byte_slice_state::IsUnset, 304 + { 305 + /// Set the `byteStart` field (required) 306 + pub fn byte_start( 307 + mut self, 308 + value: impl Into<i64>, 309 + ) -> ByteSliceBuilder<S, byte_slice_state::SetByteStart<St>> { 310 + self._fields.1 = Option::Some(value.into()); 311 + ByteSliceBuilder { 312 + _state: PhantomData, 313 + _fields: self._fields, 314 + _type: PhantomData, 315 + } 316 + } 317 + } 318 + 319 + impl<S: BosStr, St> ByteSliceBuilder<S, St> 320 + where 321 + St: byte_slice_state::State, 322 + St::ByteEnd: byte_slice_state::IsSet, 323 + St::ByteStart: byte_slice_state::IsSet, 324 + { 325 + /// Build the final struct. 326 + pub fn build(self) -> ByteSlice<S> { 327 + ByteSlice { 328 + byte_end: self._fields.0.unwrap(), 329 + byte_start: self._fields.1.unwrap(), 330 + extra_data: Default::default(), 331 + } 332 + } 333 + /// Build the final struct with custom extra_data. 334 + pub fn build_with_data( 335 + self, 336 + extra_data: BTreeMap<SmolStr, Data<S>>, 337 + ) -> ByteSlice<S> { 338 + ByteSlice { 339 + byte_end: self._fields.0.unwrap(), 340 + byte_start: self._fields.1.unwrap(), 341 + extra_data: Some(extra_data), 342 + } 343 + } 344 + } 345 + 346 + fn lexicon_doc_app_bsky_richtext_facet() -> LexiconDoc<'static> { 347 + #[allow(unused_imports)] 348 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 349 + use jacquard_lexicon::lexicon::*; 350 + use alloc::collections::BTreeMap; 351 + LexiconDoc { 352 + lexicon: Lexicon::Lexicon1, 353 + id: CowStr::new_static("app.bsky.richtext.facet"), 354 + defs: { 355 + let mut map = BTreeMap::new(); 356 + map.insert( 357 + SmolStr::new_static("byteSlice"), 358 + LexUserType::Object(LexObject { 359 + description: Some( 360 + CowStr::new_static( 361 + "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.", 362 + ), 363 + ), 364 + required: Some( 365 + vec![ 366 + SmolStr::new_static("byteStart"), 367 + SmolStr::new_static("byteEnd") 368 + ], 369 + ), 370 + properties: { 371 + #[allow(unused_mut)] 372 + let mut map = BTreeMap::new(); 373 + map.insert( 374 + SmolStr::new_static("byteEnd"), 375 + LexObjectProperty::Integer(LexInteger { 376 + minimum: Some(0i64), 377 + ..Default::default() 378 + }), 379 + ); 380 + map.insert( 381 + SmolStr::new_static("byteStart"), 382 + LexObjectProperty::Integer(LexInteger { 383 + minimum: Some(0i64), 384 + ..Default::default() 385 + }), 386 + ); 387 + map 388 + }, 389 + ..Default::default() 390 + }), 391 + ); 392 + map.insert( 393 + SmolStr::new_static("link"), 394 + LexUserType::Object(LexObject { 395 + description: Some( 396 + CowStr::new_static( 397 + "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.", 398 + ), 399 + ), 400 + required: Some(vec![SmolStr::new_static("uri")]), 401 + properties: { 402 + #[allow(unused_mut)] 403 + let mut map = BTreeMap::new(); 404 + map.insert( 405 + SmolStr::new_static("uri"), 406 + LexObjectProperty::String(LexString { 407 + format: Some(LexStringFormat::Uri), 408 + ..Default::default() 409 + }), 410 + ); 411 + map 412 + }, 413 + ..Default::default() 414 + }), 415 + ); 416 + map.insert( 417 + SmolStr::new_static("main"), 418 + LexUserType::Object(LexObject { 419 + description: Some( 420 + CowStr::new_static( 421 + "Annotation of a sub-string within rich text.", 422 + ), 423 + ), 424 + required: Some( 425 + vec![ 426 + SmolStr::new_static("index"), SmolStr::new_static("features") 427 + ], 428 + ), 429 + properties: { 430 + #[allow(unused_mut)] 431 + let mut map = BTreeMap::new(); 432 + map.insert( 433 + SmolStr::new_static("features"), 434 + LexObjectProperty::Array(LexArray { 435 + items: LexArrayItem::Union(LexRefUnion { 436 + refs: vec![ 437 + CowStr::new_static("#mention"), CowStr::new_static("#link"), 438 + CowStr::new_static("#tag") 439 + ], 440 + ..Default::default() 441 + }), 442 + ..Default::default() 443 + }), 444 + ); 445 + map.insert( 446 + SmolStr::new_static("index"), 447 + LexObjectProperty::Ref(LexRef { 448 + r#ref: CowStr::new_static("#byteSlice"), 449 + ..Default::default() 450 + }), 451 + ); 452 + map 453 + }, 454 + ..Default::default() 455 + }), 456 + ); 457 + map.insert( 458 + SmolStr::new_static("mention"), 459 + LexUserType::Object(LexObject { 460 + description: Some( 461 + CowStr::new_static( 462 + "Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.", 463 + ), 464 + ), 465 + required: Some(vec![SmolStr::new_static("did")]), 466 + properties: { 467 + #[allow(unused_mut)] 468 + let mut map = BTreeMap::new(); 469 + map.insert( 470 + SmolStr::new_static("did"), 471 + LexObjectProperty::String(LexString { 472 + format: Some(LexStringFormat::Did), 473 + ..Default::default() 474 + }), 475 + ); 476 + map 477 + }, 478 + ..Default::default() 479 + }), 480 + ); 481 + map.insert( 482 + SmolStr::new_static("tag"), 483 + LexUserType::Object(LexObject { 484 + description: Some( 485 + CowStr::new_static( 486 + "Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').", 487 + ), 488 + ), 489 + required: Some(vec![SmolStr::new_static("tag")]), 490 + properties: { 491 + #[allow(unused_mut)] 492 + let mut map = BTreeMap::new(); 493 + map.insert( 494 + SmolStr::new_static("tag"), 495 + LexObjectProperty::String(LexString { 496 + max_length: Some(640usize), 497 + max_graphemes: Some(64usize), 498 + ..Default::default() 499 + }), 500 + ); 501 + map 502 + }, 503 + ..Default::default() 504 + }), 505 + ); 506 + map 507 + }, 508 + ..Default::default() 509 + } 510 + } 511 + 512 + pub mod link_state { 513 + 514 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 515 + #[allow(unused)] 516 + use ::core::marker::PhantomData; 517 + mod sealed { 518 + pub trait Sealed {} 519 + } 520 + /// State trait tracking which required fields have been set 521 + pub trait State: sealed::Sealed { 522 + type Uri; 523 + } 524 + /// Empty state - all required fields are unset 525 + pub struct Empty(()); 526 + impl sealed::Sealed for Empty {} 527 + impl State for Empty { 528 + type Uri = Unset; 529 + } 530 + ///State transition - sets the `uri` field to Set 531 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 532 + impl<St: State> sealed::Sealed for SetUri<St> {} 533 + impl<St: State> State for SetUri<St> { 534 + type Uri = Set<members::uri>; 535 + } 536 + /// Marker types for field names 537 + #[allow(non_camel_case_types)] 538 + pub mod members { 539 + ///Marker type for the `uri` field 540 + pub struct uri(()); 541 + } 542 + } 543 + 544 + /// Builder for constructing an instance of this type. 545 + pub struct LinkBuilder<S: BosStr, St: link_state::State> { 546 + _state: PhantomData<fn() -> St>, 547 + _fields: (Option<UriValue<S>>,), 548 + _type: PhantomData<fn() -> S>, 549 + } 550 + 551 + impl<S: BosStr> Link<S> { 552 + /// Create a new builder for this type. 553 + pub fn new() -> LinkBuilder<S, link_state::Empty> { 554 + LinkBuilder::new() 555 + } 556 + } 557 + 558 + impl<S: BosStr> LinkBuilder<S, link_state::Empty> { 559 + /// Create a new builder with all fields unset. 560 + pub fn new() -> Self { 561 + LinkBuilder { 562 + _state: PhantomData, 563 + _fields: (None,), 564 + _type: PhantomData, 565 + } 566 + } 567 + } 568 + 569 + impl<S: BosStr, St> LinkBuilder<S, St> 570 + where 571 + St: link_state::State, 572 + St::Uri: link_state::IsUnset, 573 + { 574 + /// Set the `uri` field (required) 575 + pub fn uri( 576 + mut self, 577 + value: impl Into<UriValue<S>>, 578 + ) -> LinkBuilder<S, link_state::SetUri<St>> { 579 + self._fields.0 = Option::Some(value.into()); 580 + LinkBuilder { 581 + _state: PhantomData, 582 + _fields: self._fields, 583 + _type: PhantomData, 584 + } 585 + } 586 + } 587 + 588 + impl<S: BosStr, St> LinkBuilder<S, St> 589 + where 590 + St: link_state::State, 591 + St::Uri: link_state::IsSet, 592 + { 593 + /// Build the final struct. 594 + pub fn build(self) -> Link<S> { 595 + Link { 596 + uri: self._fields.0.unwrap(), 597 + extra_data: Default::default(), 598 + } 599 + } 600 + /// Build the final struct with custom extra_data. 601 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Link<S> { 602 + Link { 603 + uri: self._fields.0.unwrap(), 604 + extra_data: Some(extra_data), 605 + } 606 + } 607 + } 608 + 609 + pub mod facet_state { 610 + 611 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 612 + #[allow(unused)] 613 + use ::core::marker::PhantomData; 614 + mod sealed { 615 + pub trait Sealed {} 616 + } 617 + /// State trait tracking which required fields have been set 618 + pub trait State: sealed::Sealed { 619 + type Index; 620 + type Features; 621 + } 622 + /// Empty state - all required fields are unset 623 + pub struct Empty(()); 624 + impl sealed::Sealed for Empty {} 625 + impl State for Empty { 626 + type Index = Unset; 627 + type Features = Unset; 628 + } 629 + ///State transition - sets the `index` field to Set 630 + pub struct SetIndex<St: State = Empty>(PhantomData<fn() -> St>); 631 + impl<St: State> sealed::Sealed for SetIndex<St> {} 632 + impl<St: State> State for SetIndex<St> { 633 + type Index = Set<members::index>; 634 + type Features = St::Features; 635 + } 636 + ///State transition - sets the `features` field to Set 637 + pub struct SetFeatures<St: State = Empty>(PhantomData<fn() -> St>); 638 + impl<St: State> sealed::Sealed for SetFeatures<St> {} 639 + impl<St: State> State for SetFeatures<St> { 640 + type Index = St::Index; 641 + type Features = Set<members::features>; 642 + } 643 + /// Marker types for field names 644 + #[allow(non_camel_case_types)] 645 + pub mod members { 646 + ///Marker type for the `index` field 647 + pub struct index(()); 648 + ///Marker type for the `features` field 649 + pub struct features(()); 650 + } 651 + } 652 + 653 + /// Builder for constructing an instance of this type. 654 + pub struct FacetBuilder<S: BosStr, St: facet_state::State> { 655 + _state: PhantomData<fn() -> St>, 656 + _fields: (Option<Vec<FacetFeaturesItem<S>>>, Option<facet::ByteSlice<S>>), 657 + _type: PhantomData<fn() -> S>, 658 + } 659 + 660 + impl<S: BosStr> Facet<S> { 661 + /// Create a new builder for this type. 662 + pub fn new() -> FacetBuilder<S, facet_state::Empty> { 663 + FacetBuilder::new() 664 + } 665 + } 666 + 667 + impl<S: BosStr> FacetBuilder<S, facet_state::Empty> { 668 + /// Create a new builder with all fields unset. 669 + pub fn new() -> Self { 670 + FacetBuilder { 671 + _state: PhantomData, 672 + _fields: (None, None), 673 + _type: PhantomData, 674 + } 675 + } 676 + } 677 + 678 + impl<S: BosStr, St> FacetBuilder<S, St> 679 + where 680 + St: facet_state::State, 681 + St::Features: facet_state::IsUnset, 682 + { 683 + /// Set the `features` field (required) 684 + pub fn features( 685 + mut self, 686 + value: impl Into<Vec<FacetFeaturesItem<S>>>, 687 + ) -> FacetBuilder<S, facet_state::SetFeatures<St>> { 688 + self._fields.0 = Option::Some(value.into()); 689 + FacetBuilder { 690 + _state: PhantomData, 691 + _fields: self._fields, 692 + _type: PhantomData, 693 + } 694 + } 695 + } 696 + 697 + impl<S: BosStr, St> FacetBuilder<S, St> 698 + where 699 + St: facet_state::State, 700 + St::Index: facet_state::IsUnset, 701 + { 702 + /// Set the `index` field (required) 703 + pub fn index( 704 + mut self, 705 + value: impl Into<facet::ByteSlice<S>>, 706 + ) -> FacetBuilder<S, facet_state::SetIndex<St>> { 707 + self._fields.1 = Option::Some(value.into()); 708 + FacetBuilder { 709 + _state: PhantomData, 710 + _fields: self._fields, 711 + _type: PhantomData, 712 + } 713 + } 714 + } 715 + 716 + impl<S: BosStr, St> FacetBuilder<S, St> 717 + where 718 + St: facet_state::State, 719 + St::Index: facet_state::IsSet, 720 + St::Features: facet_state::IsSet, 721 + { 722 + /// Build the final struct. 723 + pub fn build(self) -> Facet<S> { 724 + Facet { 725 + features: self._fields.0.unwrap(), 726 + index: self._fields.1.unwrap(), 727 + extra_data: Default::default(), 728 + } 729 + } 730 + /// Build the final struct with custom extra_data. 731 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Facet<S> { 732 + Facet { 733 + features: self._fields.0.unwrap(), 734 + index: self._fields.1.unwrap(), 735 + extra_data: Some(extra_data), 736 + } 737 + } 738 + } 739 + 740 + pub mod mention_state { 741 + 742 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 743 + #[allow(unused)] 744 + use ::core::marker::PhantomData; 745 + mod sealed { 746 + pub trait Sealed {} 747 + } 748 + /// State trait tracking which required fields have been set 749 + pub trait State: sealed::Sealed { 750 + type Did; 751 + } 752 + /// Empty state - all required fields are unset 753 + pub struct Empty(()); 754 + impl sealed::Sealed for Empty {} 755 + impl State for Empty { 756 + type Did = Unset; 757 + } 758 + ///State transition - sets the `did` field to Set 759 + pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>); 760 + impl<St: State> sealed::Sealed for SetDid<St> {} 761 + impl<St: State> State for SetDid<St> { 762 + type Did = Set<members::did>; 763 + } 764 + /// Marker types for field names 765 + #[allow(non_camel_case_types)] 766 + pub mod members { 767 + ///Marker type for the `did` field 768 + pub struct did(()); 769 + } 770 + } 771 + 772 + /// Builder for constructing an instance of this type. 773 + pub struct MentionBuilder<S: BosStr, St: mention_state::State> { 774 + _state: PhantomData<fn() -> St>, 775 + _fields: (Option<Did<S>>,), 776 + _type: PhantomData<fn() -> S>, 777 + } 778 + 779 + impl<S: BosStr> Mention<S> { 780 + /// Create a new builder for this type. 781 + pub fn new() -> MentionBuilder<S, mention_state::Empty> { 782 + MentionBuilder::new() 783 + } 784 + } 785 + 786 + impl<S: BosStr> MentionBuilder<S, mention_state::Empty> { 787 + /// Create a new builder with all fields unset. 788 + pub fn new() -> Self { 789 + MentionBuilder { 790 + _state: PhantomData, 791 + _fields: (None,), 792 + _type: PhantomData, 793 + } 794 + } 795 + } 796 + 797 + impl<S: BosStr, St> MentionBuilder<S, St> 798 + where 799 + St: mention_state::State, 800 + St::Did: mention_state::IsUnset, 801 + { 802 + /// Set the `did` field (required) 803 + pub fn did( 804 + mut self, 805 + value: impl Into<Did<S>>, 806 + ) -> MentionBuilder<S, mention_state::SetDid<St>> { 807 + self._fields.0 = Option::Some(value.into()); 808 + MentionBuilder { 809 + _state: PhantomData, 810 + _fields: self._fields, 811 + _type: PhantomData, 812 + } 813 + } 814 + } 815 + 816 + impl<S: BosStr, St> MentionBuilder<S, St> 817 + where 818 + St: mention_state::State, 819 + St::Did: mention_state::IsSet, 820 + { 821 + /// Build the final struct. 822 + pub fn build(self) -> Mention<S> { 823 + Mention { 824 + did: self._fields.0.unwrap(), 825 + extra_data: Default::default(), 826 + } 827 + } 828 + /// Build the final struct with custom extra_data. 829 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Mention<S> { 830 + Mention { 831 + did: self._fields.0.unwrap(), 832 + extra_data: Some(extra_data), 833 + } 834 + } 835 + }
+45
crates/jacquard-codegen-tests/src/generated/pretty/builder_types.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + /// Marker type indicating a builder field has been set 7 + pub struct Set<T>(pub T); 8 + impl<T> Set<T> { 9 + /// Extract the inner value 10 + #[inline] 11 + pub fn into_inner(self) -> T { 12 + self.0 13 + } 14 + } 15 + 16 + /// Marker type indicating a builder field has not been set 17 + pub struct Unset; 18 + /// Trait indicating a builder field is set (has a value) 19 + 20 + #[jacquard_common::deps::codegen::rustversion::attr( 21 + since(1.78.0), 22 + diagnostic::on_unimplemented( 23 + message = "the field `{Self}` was not set, but this method requires it to be set", 24 + label = "the field `{Self}` was not set" 25 + ) 26 + )] 27 + pub trait IsSet: private::Sealed {} 28 + /// Trait indicating a builder field is unset (no value yet) 29 + 30 + #[jacquard_common::deps::codegen::rustversion::attr( 31 + since(1.78.0), 32 + diagnostic::on_unimplemented( 33 + message = "the field `{Self}` was already set, but this method requires it to be unset", 34 + label = "the field `{Self}` was already set" 35 + ) 36 + )] 37 + pub trait IsUnset: private::Sealed {} 38 + impl<T> IsSet for Set<T> {} 39 + impl IsUnset for Unset {} 40 + mod private { 41 + /// Sealed trait to prevent external implementations 42 + pub trait Sealed {} 43 + impl<T> Sealed for super::Set<T> {} 44 + impl Sealed for super::Unset {} 45 + }
+7
crates/jacquard-codegen-tests/src/generated/pretty/com_atproto.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod label; 7 + pub mod repo;
+1838
crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/label.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: com.atproto.label.defs 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + use jacquard_common::deps::bytes::Bytes; 15 + 16 + #[allow(unused_imports)] 17 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 18 + use jacquard_common::deps::smol_str::SmolStr; 19 + use jacquard_common::types::string::{Did, Cid, Datetime, Language, UriValue}; 20 + use jacquard_common::types::value::Data; 21 + use jacquard_derive::IntoStatic; 22 + use jacquard_lexicon::lexicon::LexiconDoc; 23 + use jacquard_lexicon::schema::LexiconSchema; 24 + 25 + #[allow(unused_imports)] 26 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 27 + use serde::{Serialize, Deserialize}; 28 + use crate::pretty::com_atproto::label; 29 + /// Metadata tag on an atproto resource (eg, repo or record). 30 + 31 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 32 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 33 + pub struct Label<S: BosStr = DefaultStr> { 34 + ///Optionally, CID specifying the specific version of 'uri' resource this label applies to. 35 + #[serde(skip_serializing_if = "Option::is_none")] 36 + pub cid: Option<Cid<S>>, 37 + ///Timestamp when this label was created. 38 + pub cts: Datetime, 39 + ///Timestamp at which this label expires (no longer applies). 40 + #[serde(skip_serializing_if = "Option::is_none")] 41 + pub exp: Option<Datetime>, 42 + ///If true, this is a negation label, overwriting a previous label. 43 + #[serde(skip_serializing_if = "Option::is_none")] 44 + pub neg: Option<bool>, 45 + ///Signature of dag-cbor encoded label. 46 + #[serde(skip_serializing_if = "Option::is_none")] 47 + #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")] 48 + pub sig: Option<Bytes>, 49 + ///DID of the actor who created this label. 50 + pub src: Did<S>, 51 + ///AT URI of the record, repository (account), or other resource that this label applies to. 52 + pub uri: UriValue<S>, 53 + ///The short string name of the value or type of this label. 54 + pub val: S, 55 + ///The AT Protocol version of the label object. 56 + #[serde(skip_serializing_if = "Option::is_none")] 57 + pub ver: Option<i64>, 58 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 59 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 60 + } 61 + 62 + 63 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 64 + pub enum LabelValue<S: BosStr = DefaultStr> { 65 + Hide, 66 + NoPromote, 67 + Warn, 68 + NoUnauthenticated, 69 + DmcaViolation, 70 + Doxxing, 71 + Porn, 72 + Sexual, 73 + Nudity, 74 + Nsfl, 75 + Gore, 76 + Other(S), 77 + } 78 + 79 + impl<S: BosStr> LabelValue<S> { 80 + pub fn as_str(&self) -> &str { 81 + match self { 82 + Self::Hide => "!hide", 83 + Self::NoPromote => "!no-promote", 84 + Self::Warn => "!warn", 85 + Self::NoUnauthenticated => "!no-unauthenticated", 86 + Self::DmcaViolation => "dmca-violation", 87 + Self::Doxxing => "doxxing", 88 + Self::Porn => "porn", 89 + Self::Sexual => "sexual", 90 + Self::Nudity => "nudity", 91 + Self::Nsfl => "nsfl", 92 + Self::Gore => "gore", 93 + Self::Other(s) => s.as_ref(), 94 + } 95 + } 96 + /// Construct from a string-like value, matching known values. 97 + pub fn from_value(s: S) -> Self { 98 + match s.as_ref() { 99 + "!hide" => Self::Hide, 100 + "!no-promote" => Self::NoPromote, 101 + "!warn" => Self::Warn, 102 + "!no-unauthenticated" => Self::NoUnauthenticated, 103 + "dmca-violation" => Self::DmcaViolation, 104 + "doxxing" => Self::Doxxing, 105 + "porn" => Self::Porn, 106 + "sexual" => Self::Sexual, 107 + "nudity" => Self::Nudity, 108 + "nsfl" => Self::Nsfl, 109 + "gore" => Self::Gore, 110 + _ => Self::Other(s), 111 + } 112 + } 113 + } 114 + 115 + impl<S: BosStr> AsRef<str> for LabelValue<S> { 116 + fn as_ref(&self) -> &str { 117 + self.as_str() 118 + } 119 + } 120 + 121 + impl<S: BosStr> core::fmt::Display for LabelValue<S> { 122 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 123 + write!(f, "{}", self.as_str()) 124 + } 125 + } 126 + 127 + impl<S: BosStr> Serialize for LabelValue<S> { 128 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 129 + where 130 + Ser: serde::Serializer, 131 + { 132 + serializer.serialize_str(self.as_str()) 133 + } 134 + } 135 + 136 + impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for LabelValue<S> { 137 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 138 + where 139 + D: serde::Deserializer<'de>, 140 + { 141 + let s = S::deserialize(deserializer)?; 142 + Ok(Self::from_value(s)) 143 + } 144 + } 145 + 146 + impl<S: BosStr> jacquard_common::IntoStatic for LabelValue<S> 147 + where 148 + S: BosStr + jacquard_common::IntoStatic, 149 + S::Output: BosStr, 150 + { 151 + type Output = LabelValue<S::Output>; 152 + fn into_static(self) -> Self::Output { 153 + match self { 154 + LabelValue::Hide => LabelValue::Hide, 155 + LabelValue::NoPromote => LabelValue::NoPromote, 156 + LabelValue::Warn => LabelValue::Warn, 157 + LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated, 158 + LabelValue::DmcaViolation => LabelValue::DmcaViolation, 159 + LabelValue::Doxxing => LabelValue::Doxxing, 160 + LabelValue::Porn => LabelValue::Porn, 161 + LabelValue::Sexual => LabelValue::Sexual, 162 + LabelValue::Nudity => LabelValue::Nudity, 163 + LabelValue::Nsfl => LabelValue::Nsfl, 164 + LabelValue::Gore => LabelValue::Gore, 165 + LabelValue::Other(v) => LabelValue::Other(v.into_static()), 166 + } 167 + } 168 + } 169 + 170 + /// Declares a label value and its expected interpretations and behaviors. 171 + 172 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 173 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 174 + pub struct LabelValueDefinition<S: BosStr = DefaultStr> { 175 + ///Does the user need to have adult content enabled in order to configure this label? 176 + #[serde(skip_serializing_if = "Option::is_none")] 177 + pub adult_only: Option<bool>, 178 + ///What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing. 179 + pub blurs: LabelValueDefinitionBlurs<S>, 180 + ///The default setting for this label. 181 + #[serde(skip_serializing_if = "Option::is_none")] 182 + pub default_setting: Option<LabelValueDefinitionDefaultSetting<S>>, 183 + ///The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+). 184 + pub identifier: S, 185 + pub locales: Vec<label::LabelValueDefinitionStrings<S>>, 186 + ///How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. 187 + pub severity: LabelValueDefinitionSeverity<S>, 188 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 189 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 190 + } 191 + 192 + /// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing. 193 + 194 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 195 + pub enum LabelValueDefinitionBlurs<S: BosStr = DefaultStr> { 196 + Content, 197 + Media, 198 + None, 199 + Other(S), 200 + } 201 + 202 + impl<S: BosStr> LabelValueDefinitionBlurs<S> { 203 + pub fn as_str(&self) -> &str { 204 + match self { 205 + Self::Content => "content", 206 + Self::Media => "media", 207 + Self::None => "none", 208 + Self::Other(s) => s.as_ref(), 209 + } 210 + } 211 + /// Construct from a string-like value, matching known values. 212 + pub fn from_value(s: S) -> Self { 213 + match s.as_ref() { 214 + "content" => Self::Content, 215 + "media" => Self::Media, 216 + "none" => Self::None, 217 + _ => Self::Other(s), 218 + } 219 + } 220 + } 221 + 222 + impl<S: BosStr> core::fmt::Display for LabelValueDefinitionBlurs<S> { 223 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 224 + write!(f, "{}", self.as_str()) 225 + } 226 + } 227 + 228 + impl<S: BosStr> AsRef<str> for LabelValueDefinitionBlurs<S> { 229 + fn as_ref(&self) -> &str { 230 + self.as_str() 231 + } 232 + } 233 + 234 + impl<S: BosStr> Serialize for LabelValueDefinitionBlurs<S> { 235 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 236 + where 237 + Ser: serde::Serializer, 238 + { 239 + serializer.serialize_str(self.as_str()) 240 + } 241 + } 242 + 243 + impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> 244 + for LabelValueDefinitionBlurs<S> { 245 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 246 + where 247 + D: serde::Deserializer<'de>, 248 + { 249 + let s = S::deserialize(deserializer)?; 250 + Ok(Self::from_value(s)) 251 + } 252 + } 253 + 254 + impl<S: BosStr + Default> Default for LabelValueDefinitionBlurs<S> { 255 + fn default() -> Self { 256 + Self::Other(Default::default()) 257 + } 258 + } 259 + 260 + impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionBlurs<S> 261 + where 262 + S: BosStr + jacquard_common::IntoStatic, 263 + S::Output: BosStr, 264 + { 265 + type Output = LabelValueDefinitionBlurs<S::Output>; 266 + fn into_static(self) -> Self::Output { 267 + match self { 268 + LabelValueDefinitionBlurs::Content => LabelValueDefinitionBlurs::Content, 269 + LabelValueDefinitionBlurs::Media => LabelValueDefinitionBlurs::Media, 270 + LabelValueDefinitionBlurs::None => LabelValueDefinitionBlurs::None, 271 + LabelValueDefinitionBlurs::Other(v) => { 272 + LabelValueDefinitionBlurs::Other(v.into_static()) 273 + } 274 + } 275 + } 276 + } 277 + 278 + /// The default setting for this label. 279 + 280 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 281 + pub enum LabelValueDefinitionDefaultSetting<S: BosStr = DefaultStr> { 282 + Ignore, 283 + Warn, 284 + Hide, 285 + Other(S), 286 + } 287 + 288 + impl<S: BosStr> LabelValueDefinitionDefaultSetting<S> { 289 + pub fn as_str(&self) -> &str { 290 + match self { 291 + Self::Ignore => "ignore", 292 + Self::Warn => "warn", 293 + Self::Hide => "hide", 294 + Self::Other(s) => s.as_ref(), 295 + } 296 + } 297 + /// Construct from a string-like value, matching known values. 298 + pub fn from_value(s: S) -> Self { 299 + match s.as_ref() { 300 + "ignore" => Self::Ignore, 301 + "warn" => Self::Warn, 302 + "hide" => Self::Hide, 303 + _ => Self::Other(s), 304 + } 305 + } 306 + } 307 + 308 + impl<S: BosStr> core::fmt::Display for LabelValueDefinitionDefaultSetting<S> { 309 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 310 + write!(f, "{}", self.as_str()) 311 + } 312 + } 313 + 314 + impl<S: BosStr> AsRef<str> for LabelValueDefinitionDefaultSetting<S> { 315 + fn as_ref(&self) -> &str { 316 + self.as_str() 317 + } 318 + } 319 + 320 + impl<S: BosStr> Serialize for LabelValueDefinitionDefaultSetting<S> { 321 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 322 + where 323 + Ser: serde::Serializer, 324 + { 325 + serializer.serialize_str(self.as_str()) 326 + } 327 + } 328 + 329 + impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> 330 + for LabelValueDefinitionDefaultSetting<S> { 331 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 332 + where 333 + D: serde::Deserializer<'de>, 334 + { 335 + let s = S::deserialize(deserializer)?; 336 + Ok(Self::from_value(s)) 337 + } 338 + } 339 + 340 + impl<S: BosStr + Default> Default for LabelValueDefinitionDefaultSetting<S> { 341 + fn default() -> Self { 342 + Self::Other(Default::default()) 343 + } 344 + } 345 + 346 + impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionDefaultSetting<S> 347 + where 348 + S: BosStr + jacquard_common::IntoStatic, 349 + S::Output: BosStr, 350 + { 351 + type Output = LabelValueDefinitionDefaultSetting<S::Output>; 352 + fn into_static(self) -> Self::Output { 353 + match self { 354 + LabelValueDefinitionDefaultSetting::Ignore => { 355 + LabelValueDefinitionDefaultSetting::Ignore 356 + } 357 + LabelValueDefinitionDefaultSetting::Warn => { 358 + LabelValueDefinitionDefaultSetting::Warn 359 + } 360 + LabelValueDefinitionDefaultSetting::Hide => { 361 + LabelValueDefinitionDefaultSetting::Hide 362 + } 363 + LabelValueDefinitionDefaultSetting::Other(v) => { 364 + LabelValueDefinitionDefaultSetting::Other(v.into_static()) 365 + } 366 + } 367 + } 368 + } 369 + 370 + /// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. 371 + 372 + #[derive(Debug, Clone, PartialEq, Eq, Hash)] 373 + pub enum LabelValueDefinitionSeverity<S: BosStr = DefaultStr> { 374 + Inform, 375 + Alert, 376 + None, 377 + Other(S), 378 + } 379 + 380 + impl<S: BosStr> LabelValueDefinitionSeverity<S> { 381 + pub fn as_str(&self) -> &str { 382 + match self { 383 + Self::Inform => "inform", 384 + Self::Alert => "alert", 385 + Self::None => "none", 386 + Self::Other(s) => s.as_ref(), 387 + } 388 + } 389 + /// Construct from a string-like value, matching known values. 390 + pub fn from_value(s: S) -> Self { 391 + match s.as_ref() { 392 + "inform" => Self::Inform, 393 + "alert" => Self::Alert, 394 + "none" => Self::None, 395 + _ => Self::Other(s), 396 + } 397 + } 398 + } 399 + 400 + impl<S: BosStr> core::fmt::Display for LabelValueDefinitionSeverity<S> { 401 + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 402 + write!(f, "{}", self.as_str()) 403 + } 404 + } 405 + 406 + impl<S: BosStr> AsRef<str> for LabelValueDefinitionSeverity<S> { 407 + fn as_ref(&self) -> &str { 408 + self.as_str() 409 + } 410 + } 411 + 412 + impl<S: BosStr> Serialize for LabelValueDefinitionSeverity<S> { 413 + fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> 414 + where 415 + Ser: serde::Serializer, 416 + { 417 + serializer.serialize_str(self.as_str()) 418 + } 419 + } 420 + 421 + impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> 422 + for LabelValueDefinitionSeverity<S> { 423 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 424 + where 425 + D: serde::Deserializer<'de>, 426 + { 427 + let s = S::deserialize(deserializer)?; 428 + Ok(Self::from_value(s)) 429 + } 430 + } 431 + 432 + impl<S: BosStr + Default> Default for LabelValueDefinitionSeverity<S> { 433 + fn default() -> Self { 434 + Self::Other(Default::default()) 435 + } 436 + } 437 + 438 + impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionSeverity<S> 439 + where 440 + S: BosStr + jacquard_common::IntoStatic, 441 + S::Output: BosStr, 442 + { 443 + type Output = LabelValueDefinitionSeverity<S::Output>; 444 + fn into_static(self) -> Self::Output { 445 + match self { 446 + LabelValueDefinitionSeverity::Inform => LabelValueDefinitionSeverity::Inform, 447 + LabelValueDefinitionSeverity::Alert => LabelValueDefinitionSeverity::Alert, 448 + LabelValueDefinitionSeverity::None => LabelValueDefinitionSeverity::None, 449 + LabelValueDefinitionSeverity::Other(v) => { 450 + LabelValueDefinitionSeverity::Other(v.into_static()) 451 + } 452 + } 453 + } 454 + } 455 + 456 + /// Strings which describe the label in the UI, localized into a specific language. 457 + 458 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 459 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 460 + pub struct LabelValueDefinitionStrings<S: BosStr = DefaultStr> { 461 + ///A longer description of what the label means and why it might be applied. 462 + pub description: S, 463 + ///The code of the language these strings are written in. 464 + pub lang: Language, 465 + ///A short human-readable name for the label. 466 + pub name: S, 467 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 468 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 469 + } 470 + 471 + /// Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel. 472 + 473 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 474 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 475 + pub struct SelfLabel<S: BosStr = DefaultStr> { 476 + ///The short string name of the value or type of this label. 477 + pub val: S, 478 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 479 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 480 + } 481 + 482 + /// Metadata tags on an atproto record, published by the author within the record. 483 + 484 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 485 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 486 + pub struct SelfLabels<S: BosStr = DefaultStr> { 487 + pub values: Vec<label::SelfLabel<S>>, 488 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 489 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 490 + } 491 + 492 + impl<S: BosStr> LexiconSchema for Label<S> { 493 + fn nsid() -> &'static str { 494 + "com.atproto.label.defs" 495 + } 496 + fn def_name() -> &'static str { 497 + "label" 498 + } 499 + fn lexicon_doc() -> LexiconDoc<'static> { 500 + lexicon_doc_com_atproto_label_defs() 501 + } 502 + fn validate(&self) -> Result<(), ConstraintError> { 503 + { 504 + let value = &self.val; 505 + #[allow(unused_comparisons)] 506 + if <str>::len(value.as_ref()) > 128usize { 507 + return Err(ConstraintError::MaxLength { 508 + path: ValidationPath::from_field("val"), 509 + max: 128usize, 510 + actual: <str>::len(value.as_ref()), 511 + }); 512 + } 513 + } 514 + Ok(()) 515 + } 516 + } 517 + 518 + impl<S: BosStr> LexiconSchema for LabelValueDefinition<S> { 519 + fn nsid() -> &'static str { 520 + "com.atproto.label.defs" 521 + } 522 + fn def_name() -> &'static str { 523 + "labelValueDefinition" 524 + } 525 + fn lexicon_doc() -> LexiconDoc<'static> { 526 + lexicon_doc_com_atproto_label_defs() 527 + } 528 + fn validate(&self) -> Result<(), ConstraintError> { 529 + { 530 + let value = &self.identifier; 531 + #[allow(unused_comparisons)] 532 + if <str>::len(value.as_ref()) > 100usize { 533 + return Err(ConstraintError::MaxLength { 534 + path: ValidationPath::from_field("identifier"), 535 + max: 100usize, 536 + actual: <str>::len(value.as_ref()), 537 + }); 538 + } 539 + } 540 + { 541 + let value = &self.identifier; 542 + { 543 + let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); 544 + if count > 100usize { 545 + return Err(ConstraintError::MaxGraphemes { 546 + path: ValidationPath::from_field("identifier"), 547 + max: 100usize, 548 + actual: count, 549 + }); 550 + } 551 + } 552 + } 553 + Ok(()) 554 + } 555 + } 556 + 557 + impl<S: BosStr> LexiconSchema for LabelValueDefinitionStrings<S> { 558 + fn nsid() -> &'static str { 559 + "com.atproto.label.defs" 560 + } 561 + fn def_name() -> &'static str { 562 + "labelValueDefinitionStrings" 563 + } 564 + fn lexicon_doc() -> LexiconDoc<'static> { 565 + lexicon_doc_com_atproto_label_defs() 566 + } 567 + fn validate(&self) -> Result<(), ConstraintError> { 568 + { 569 + let value = &self.description; 570 + #[allow(unused_comparisons)] 571 + if <str>::len(value.as_ref()) > 100000usize { 572 + return Err(ConstraintError::MaxLength { 573 + path: ValidationPath::from_field("description"), 574 + max: 100000usize, 575 + actual: <str>::len(value.as_ref()), 576 + }); 577 + } 578 + } 579 + { 580 + let value = &self.description; 581 + { 582 + let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); 583 + if count > 10000usize { 584 + return Err(ConstraintError::MaxGraphemes { 585 + path: ValidationPath::from_field("description"), 586 + max: 10000usize, 587 + actual: count, 588 + }); 589 + } 590 + } 591 + } 592 + { 593 + let value = &self.name; 594 + #[allow(unused_comparisons)] 595 + if <str>::len(value.as_ref()) > 640usize { 596 + return Err(ConstraintError::MaxLength { 597 + path: ValidationPath::from_field("name"), 598 + max: 640usize, 599 + actual: <str>::len(value.as_ref()), 600 + }); 601 + } 602 + } 603 + { 604 + let value = &self.name; 605 + { 606 + let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); 607 + if count > 64usize { 608 + return Err(ConstraintError::MaxGraphemes { 609 + path: ValidationPath::from_field("name"), 610 + max: 64usize, 611 + actual: count, 612 + }); 613 + } 614 + } 615 + } 616 + Ok(()) 617 + } 618 + } 619 + 620 + impl<S: BosStr> LexiconSchema for SelfLabel<S> { 621 + fn nsid() -> &'static str { 622 + "com.atproto.label.defs" 623 + } 624 + fn def_name() -> &'static str { 625 + "selfLabel" 626 + } 627 + fn lexicon_doc() -> LexiconDoc<'static> { 628 + lexicon_doc_com_atproto_label_defs() 629 + } 630 + fn validate(&self) -> Result<(), ConstraintError> { 631 + { 632 + let value = &self.val; 633 + #[allow(unused_comparisons)] 634 + if <str>::len(value.as_ref()) > 128usize { 635 + return Err(ConstraintError::MaxLength { 636 + path: ValidationPath::from_field("val"), 637 + max: 128usize, 638 + actual: <str>::len(value.as_ref()), 639 + }); 640 + } 641 + } 642 + Ok(()) 643 + } 644 + } 645 + 646 + impl<S: BosStr> LexiconSchema for SelfLabels<S> { 647 + fn nsid() -> &'static str { 648 + "com.atproto.label.defs" 649 + } 650 + fn def_name() -> &'static str { 651 + "selfLabels" 652 + } 653 + fn lexicon_doc() -> LexiconDoc<'static> { 654 + lexicon_doc_com_atproto_label_defs() 655 + } 656 + fn validate(&self) -> Result<(), ConstraintError> { 657 + { 658 + let value = &self.values; 659 + #[allow(unused_comparisons)] 660 + if value.len() > 10usize { 661 + return Err(ConstraintError::MaxLength { 662 + path: ValidationPath::from_field("values"), 663 + max: 10usize, 664 + actual: value.len(), 665 + }); 666 + } 667 + } 668 + Ok(()) 669 + } 670 + } 671 + 672 + pub mod label_state { 673 + 674 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 675 + #[allow(unused)] 676 + use ::core::marker::PhantomData; 677 + mod sealed { 678 + pub trait Sealed {} 679 + } 680 + /// State trait tracking which required fields have been set 681 + pub trait State: sealed::Sealed { 682 + type Src; 683 + type Cts; 684 + type Uri; 685 + type Val; 686 + } 687 + /// Empty state - all required fields are unset 688 + pub struct Empty(()); 689 + impl sealed::Sealed for Empty {} 690 + impl State for Empty { 691 + type Src = Unset; 692 + type Cts = Unset; 693 + type Uri = Unset; 694 + type Val = Unset; 695 + } 696 + ///State transition - sets the `src` field to Set 697 + pub struct SetSrc<St: State = Empty>(PhantomData<fn() -> St>); 698 + impl<St: State> sealed::Sealed for SetSrc<St> {} 699 + impl<St: State> State for SetSrc<St> { 700 + type Src = Set<members::src>; 701 + type Cts = St::Cts; 702 + type Uri = St::Uri; 703 + type Val = St::Val; 704 + } 705 + ///State transition - sets the `cts` field to Set 706 + pub struct SetCts<St: State = Empty>(PhantomData<fn() -> St>); 707 + impl<St: State> sealed::Sealed for SetCts<St> {} 708 + impl<St: State> State for SetCts<St> { 709 + type Src = St::Src; 710 + type Cts = Set<members::cts>; 711 + type Uri = St::Uri; 712 + type Val = St::Val; 713 + } 714 + ///State transition - sets the `uri` field to Set 715 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 716 + impl<St: State> sealed::Sealed for SetUri<St> {} 717 + impl<St: State> State for SetUri<St> { 718 + type Src = St::Src; 719 + type Cts = St::Cts; 720 + type Uri = Set<members::uri>; 721 + type Val = St::Val; 722 + } 723 + ///State transition - sets the `val` field to Set 724 + pub struct SetVal<St: State = Empty>(PhantomData<fn() -> St>); 725 + impl<St: State> sealed::Sealed for SetVal<St> {} 726 + impl<St: State> State for SetVal<St> { 727 + type Src = St::Src; 728 + type Cts = St::Cts; 729 + type Uri = St::Uri; 730 + type Val = Set<members::val>; 731 + } 732 + /// Marker types for field names 733 + #[allow(non_camel_case_types)] 734 + pub mod members { 735 + ///Marker type for the `src` field 736 + pub struct src(()); 737 + ///Marker type for the `cts` field 738 + pub struct cts(()); 739 + ///Marker type for the `uri` field 740 + pub struct uri(()); 741 + ///Marker type for the `val` field 742 + pub struct val(()); 743 + } 744 + } 745 + 746 + /// Builder for constructing an instance of this type. 747 + pub struct LabelBuilder<S: BosStr, St: label_state::State> { 748 + _state: PhantomData<fn() -> St>, 749 + _fields: ( 750 + Option<Cid<S>>, 751 + Option<Datetime>, 752 + Option<Datetime>, 753 + Option<bool>, 754 + Option<Bytes>, 755 + Option<Did<S>>, 756 + Option<UriValue<S>>, 757 + Option<S>, 758 + Option<i64>, 759 + ), 760 + _type: PhantomData<fn() -> S>, 761 + } 762 + 763 + impl<S: BosStr> Label<S> { 764 + /// Create a new builder for this type. 765 + pub fn new() -> LabelBuilder<S, label_state::Empty> { 766 + LabelBuilder::new() 767 + } 768 + } 769 + 770 + impl<S: BosStr> LabelBuilder<S, label_state::Empty> { 771 + /// Create a new builder with all fields unset. 772 + pub fn new() -> Self { 773 + LabelBuilder { 774 + _state: PhantomData, 775 + _fields: (None, None, None, None, None, None, None, None, None), 776 + _type: PhantomData, 777 + } 778 + } 779 + } 780 + 781 + impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> { 782 + /// Set the `cid` field (optional) 783 + pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self { 784 + self._fields.0 = value.into(); 785 + self 786 + } 787 + /// Set the `cid` field to an Option value (optional) 788 + pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self { 789 + self._fields.0 = value; 790 + self 791 + } 792 + } 793 + 794 + impl<S: BosStr, St> LabelBuilder<S, St> 795 + where 796 + St: label_state::State, 797 + St::Cts: label_state::IsUnset, 798 + { 799 + /// Set the `cts` field (required) 800 + pub fn cts( 801 + mut self, 802 + value: impl Into<Datetime>, 803 + ) -> LabelBuilder<S, label_state::SetCts<St>> { 804 + self._fields.1 = Option::Some(value.into()); 805 + LabelBuilder { 806 + _state: PhantomData, 807 + _fields: self._fields, 808 + _type: PhantomData, 809 + } 810 + } 811 + } 812 + 813 + impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> { 814 + /// Set the `exp` field (optional) 815 + pub fn exp(mut self, value: impl Into<Option<Datetime>>) -> Self { 816 + self._fields.2 = value.into(); 817 + self 818 + } 819 + /// Set the `exp` field to an Option value (optional) 820 + pub fn maybe_exp(mut self, value: Option<Datetime>) -> Self { 821 + self._fields.2 = value; 822 + self 823 + } 824 + } 825 + 826 + impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> { 827 + /// Set the `neg` field (optional) 828 + pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self { 829 + self._fields.3 = value.into(); 830 + self 831 + } 832 + /// Set the `neg` field to an Option value (optional) 833 + pub fn maybe_neg(mut self, value: Option<bool>) -> Self { 834 + self._fields.3 = value; 835 + self 836 + } 837 + } 838 + 839 + impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> { 840 + /// Set the `sig` field (optional) 841 + pub fn sig(mut self, value: impl Into<Option<Bytes>>) -> Self { 842 + self._fields.4 = value.into(); 843 + self 844 + } 845 + /// Set the `sig` field to an Option value (optional) 846 + pub fn maybe_sig(mut self, value: Option<Bytes>) -> Self { 847 + self._fields.4 = value; 848 + self 849 + } 850 + } 851 + 852 + impl<S: BosStr, St> LabelBuilder<S, St> 853 + where 854 + St: label_state::State, 855 + St::Src: label_state::IsUnset, 856 + { 857 + /// Set the `src` field (required) 858 + pub fn src( 859 + mut self, 860 + value: impl Into<Did<S>>, 861 + ) -> LabelBuilder<S, label_state::SetSrc<St>> { 862 + self._fields.5 = Option::Some(value.into()); 863 + LabelBuilder { 864 + _state: PhantomData, 865 + _fields: self._fields, 866 + _type: PhantomData, 867 + } 868 + } 869 + } 870 + 871 + impl<S: BosStr, St> LabelBuilder<S, St> 872 + where 873 + St: label_state::State, 874 + St::Uri: label_state::IsUnset, 875 + { 876 + /// Set the `uri` field (required) 877 + pub fn uri( 878 + mut self, 879 + value: impl Into<UriValue<S>>, 880 + ) -> LabelBuilder<S, label_state::SetUri<St>> { 881 + self._fields.6 = Option::Some(value.into()); 882 + LabelBuilder { 883 + _state: PhantomData, 884 + _fields: self._fields, 885 + _type: PhantomData, 886 + } 887 + } 888 + } 889 + 890 + impl<S: BosStr, St> LabelBuilder<S, St> 891 + where 892 + St: label_state::State, 893 + St::Val: label_state::IsUnset, 894 + { 895 + /// Set the `val` field (required) 896 + pub fn val( 897 + mut self, 898 + value: impl Into<S>, 899 + ) -> LabelBuilder<S, label_state::SetVal<St>> { 900 + self._fields.7 = Option::Some(value.into()); 901 + LabelBuilder { 902 + _state: PhantomData, 903 + _fields: self._fields, 904 + _type: PhantomData, 905 + } 906 + } 907 + } 908 + 909 + impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> { 910 + /// Set the `ver` field (optional) 911 + pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self { 912 + self._fields.8 = value.into(); 913 + self 914 + } 915 + /// Set the `ver` field to an Option value (optional) 916 + pub fn maybe_ver(mut self, value: Option<i64>) -> Self { 917 + self._fields.8 = value; 918 + self 919 + } 920 + } 921 + 922 + impl<S: BosStr, St> LabelBuilder<S, St> 923 + where 924 + St: label_state::State, 925 + St::Src: label_state::IsSet, 926 + St::Cts: label_state::IsSet, 927 + St::Uri: label_state::IsSet, 928 + St::Val: label_state::IsSet, 929 + { 930 + /// Build the final struct. 931 + pub fn build(self) -> Label<S> { 932 + Label { 933 + cid: self._fields.0, 934 + cts: self._fields.1.unwrap(), 935 + exp: self._fields.2, 936 + neg: self._fields.3, 937 + sig: self._fields.4, 938 + src: self._fields.5.unwrap(), 939 + uri: self._fields.6.unwrap(), 940 + val: self._fields.7.unwrap(), 941 + ver: self._fields.8, 942 + extra_data: Default::default(), 943 + } 944 + } 945 + /// Build the final struct with custom extra_data. 946 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Label<S> { 947 + Label { 948 + cid: self._fields.0, 949 + cts: self._fields.1.unwrap(), 950 + exp: self._fields.2, 951 + neg: self._fields.3, 952 + sig: self._fields.4, 953 + src: self._fields.5.unwrap(), 954 + uri: self._fields.6.unwrap(), 955 + val: self._fields.7.unwrap(), 956 + ver: self._fields.8, 957 + extra_data: Some(extra_data), 958 + } 959 + } 960 + } 961 + 962 + fn lexicon_doc_com_atproto_label_defs() -> LexiconDoc<'static> { 963 + #[allow(unused_imports)] 964 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 965 + use jacquard_lexicon::lexicon::*; 966 + use alloc::collections::BTreeMap; 967 + LexiconDoc { 968 + lexicon: Lexicon::Lexicon1, 969 + id: CowStr::new_static("com.atproto.label.defs"), 970 + defs: { 971 + let mut map = BTreeMap::new(); 972 + map.insert( 973 + SmolStr::new_static("label"), 974 + LexUserType::Object(LexObject { 975 + description: Some( 976 + CowStr::new_static( 977 + "Metadata tag on an atproto resource (eg, repo or record).", 978 + ), 979 + ), 980 + required: Some( 981 + vec![ 982 + SmolStr::new_static("src"), SmolStr::new_static("uri"), 983 + SmolStr::new_static("val"), SmolStr::new_static("cts") 984 + ], 985 + ), 986 + properties: { 987 + #[allow(unused_mut)] 988 + let mut map = BTreeMap::new(); 989 + map.insert( 990 + SmolStr::new_static("cid"), 991 + LexObjectProperty::String(LexString { 992 + description: Some( 993 + CowStr::new_static( 994 + "Optionally, CID specifying the specific version of 'uri' resource this label applies to.", 995 + ), 996 + ), 997 + format: Some(LexStringFormat::Cid), 998 + ..Default::default() 999 + }), 1000 + ); 1001 + map.insert( 1002 + SmolStr::new_static("cts"), 1003 + LexObjectProperty::String(LexString { 1004 + description: Some( 1005 + CowStr::new_static("Timestamp when this label was created."), 1006 + ), 1007 + format: Some(LexStringFormat::Datetime), 1008 + ..Default::default() 1009 + }), 1010 + ); 1011 + map.insert( 1012 + SmolStr::new_static("exp"), 1013 + LexObjectProperty::String(LexString { 1014 + description: Some( 1015 + CowStr::new_static( 1016 + "Timestamp at which this label expires (no longer applies).", 1017 + ), 1018 + ), 1019 + format: Some(LexStringFormat::Datetime), 1020 + ..Default::default() 1021 + }), 1022 + ); 1023 + map.insert( 1024 + SmolStr::new_static("neg"), 1025 + LexObjectProperty::Boolean(LexBoolean { 1026 + ..Default::default() 1027 + }), 1028 + ); 1029 + map.insert( 1030 + SmolStr::new_static("sig"), 1031 + LexObjectProperty::Bytes(LexBytes { ..Default::default() }), 1032 + ); 1033 + map.insert( 1034 + SmolStr::new_static("src"), 1035 + LexObjectProperty::String(LexString { 1036 + description: Some( 1037 + CowStr::new_static( 1038 + "DID of the actor who created this label.", 1039 + ), 1040 + ), 1041 + format: Some(LexStringFormat::Did), 1042 + ..Default::default() 1043 + }), 1044 + ); 1045 + map.insert( 1046 + SmolStr::new_static("uri"), 1047 + LexObjectProperty::String(LexString { 1048 + description: Some( 1049 + CowStr::new_static( 1050 + "AT URI of the record, repository (account), or other resource that this label applies to.", 1051 + ), 1052 + ), 1053 + format: Some(LexStringFormat::Uri), 1054 + ..Default::default() 1055 + }), 1056 + ); 1057 + map.insert( 1058 + SmolStr::new_static("val"), 1059 + LexObjectProperty::String(LexString { 1060 + description: Some( 1061 + CowStr::new_static( 1062 + "The short string name of the value or type of this label.", 1063 + ), 1064 + ), 1065 + max_length: Some(128usize), 1066 + ..Default::default() 1067 + }), 1068 + ); 1069 + map.insert( 1070 + SmolStr::new_static("ver"), 1071 + LexObjectProperty::Integer(LexInteger { 1072 + ..Default::default() 1073 + }), 1074 + ); 1075 + map 1076 + }, 1077 + ..Default::default() 1078 + }), 1079 + ); 1080 + map.insert( 1081 + SmolStr::new_static("labelValue"), 1082 + LexUserType::String(LexString { ..Default::default() }), 1083 + ); 1084 + map.insert( 1085 + SmolStr::new_static("labelValueDefinition"), 1086 + LexUserType::Object(LexObject { 1087 + description: Some( 1088 + CowStr::new_static( 1089 + "Declares a label value and its expected interpretations and behaviors.", 1090 + ), 1091 + ), 1092 + required: Some( 1093 + vec![ 1094 + SmolStr::new_static("identifier"), 1095 + SmolStr::new_static("severity"), 1096 + SmolStr::new_static("blurs"), SmolStr::new_static("locales") 1097 + ], 1098 + ), 1099 + properties: { 1100 + #[allow(unused_mut)] 1101 + let mut map = BTreeMap::new(); 1102 + map.insert( 1103 + SmolStr::new_static("adultOnly"), 1104 + LexObjectProperty::Boolean(LexBoolean { 1105 + ..Default::default() 1106 + }), 1107 + ); 1108 + map.insert( 1109 + SmolStr::new_static("blurs"), 1110 + LexObjectProperty::String(LexString { 1111 + description: Some( 1112 + CowStr::new_static( 1113 + "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.", 1114 + ), 1115 + ), 1116 + ..Default::default() 1117 + }), 1118 + ); 1119 + map.insert( 1120 + SmolStr::new_static("defaultSetting"), 1121 + LexObjectProperty::String(LexString { 1122 + description: Some( 1123 + CowStr::new_static("The default setting for this label."), 1124 + ), 1125 + ..Default::default() 1126 + }), 1127 + ); 1128 + map.insert( 1129 + SmolStr::new_static("identifier"), 1130 + LexObjectProperty::String(LexString { 1131 + description: Some( 1132 + CowStr::new_static( 1133 + "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).", 1134 + ), 1135 + ), 1136 + max_length: Some(100usize), 1137 + max_graphemes: Some(100usize), 1138 + ..Default::default() 1139 + }), 1140 + ); 1141 + map.insert( 1142 + SmolStr::new_static("locales"), 1143 + LexObjectProperty::Array(LexArray { 1144 + items: LexArrayItem::Ref(LexRef { 1145 + r#ref: CowStr::new_static("#labelValueDefinitionStrings"), 1146 + ..Default::default() 1147 + }), 1148 + ..Default::default() 1149 + }), 1150 + ); 1151 + map.insert( 1152 + SmolStr::new_static("severity"), 1153 + LexObjectProperty::String(LexString { 1154 + description: Some( 1155 + CowStr::new_static( 1156 + "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.", 1157 + ), 1158 + ), 1159 + ..Default::default() 1160 + }), 1161 + ); 1162 + map 1163 + }, 1164 + ..Default::default() 1165 + }), 1166 + ); 1167 + map.insert( 1168 + SmolStr::new_static("labelValueDefinitionStrings"), 1169 + LexUserType::Object(LexObject { 1170 + description: Some( 1171 + CowStr::new_static( 1172 + "Strings which describe the label in the UI, localized into a specific language.", 1173 + ), 1174 + ), 1175 + required: Some( 1176 + vec![ 1177 + SmolStr::new_static("lang"), SmolStr::new_static("name"), 1178 + SmolStr::new_static("description") 1179 + ], 1180 + ), 1181 + properties: { 1182 + #[allow(unused_mut)] 1183 + let mut map = BTreeMap::new(); 1184 + map.insert( 1185 + SmolStr::new_static("description"), 1186 + LexObjectProperty::String(LexString { 1187 + description: Some( 1188 + CowStr::new_static( 1189 + "A longer description of what the label means and why it might be applied.", 1190 + ), 1191 + ), 1192 + max_length: Some(100000usize), 1193 + max_graphemes: Some(10000usize), 1194 + ..Default::default() 1195 + }), 1196 + ); 1197 + map.insert( 1198 + SmolStr::new_static("lang"), 1199 + LexObjectProperty::String(LexString { 1200 + description: Some( 1201 + CowStr::new_static( 1202 + "The code of the language these strings are written in.", 1203 + ), 1204 + ), 1205 + format: Some(LexStringFormat::Language), 1206 + ..Default::default() 1207 + }), 1208 + ); 1209 + map.insert( 1210 + SmolStr::new_static("name"), 1211 + LexObjectProperty::String(LexString { 1212 + description: Some( 1213 + CowStr::new_static( 1214 + "A short human-readable name for the label.", 1215 + ), 1216 + ), 1217 + max_length: Some(640usize), 1218 + max_graphemes: Some(64usize), 1219 + ..Default::default() 1220 + }), 1221 + ); 1222 + map 1223 + }, 1224 + ..Default::default() 1225 + }), 1226 + ); 1227 + map.insert( 1228 + SmolStr::new_static("selfLabel"), 1229 + LexUserType::Object(LexObject { 1230 + description: Some( 1231 + CowStr::new_static( 1232 + "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.", 1233 + ), 1234 + ), 1235 + required: Some(vec![SmolStr::new_static("val")]), 1236 + properties: { 1237 + #[allow(unused_mut)] 1238 + let mut map = BTreeMap::new(); 1239 + map.insert( 1240 + SmolStr::new_static("val"), 1241 + LexObjectProperty::String(LexString { 1242 + description: Some( 1243 + CowStr::new_static( 1244 + "The short string name of the value or type of this label.", 1245 + ), 1246 + ), 1247 + max_length: Some(128usize), 1248 + ..Default::default() 1249 + }), 1250 + ); 1251 + map 1252 + }, 1253 + ..Default::default() 1254 + }), 1255 + ); 1256 + map.insert( 1257 + SmolStr::new_static("selfLabels"), 1258 + LexUserType::Object(LexObject { 1259 + description: Some( 1260 + CowStr::new_static( 1261 + "Metadata tags on an atproto record, published by the author within the record.", 1262 + ), 1263 + ), 1264 + required: Some(vec![SmolStr::new_static("values")]), 1265 + properties: { 1266 + #[allow(unused_mut)] 1267 + let mut map = BTreeMap::new(); 1268 + map.insert( 1269 + SmolStr::new_static("values"), 1270 + LexObjectProperty::Array(LexArray { 1271 + items: LexArrayItem::Ref(LexRef { 1272 + r#ref: CowStr::new_static("#selfLabel"), 1273 + ..Default::default() 1274 + }), 1275 + max_length: Some(10usize), 1276 + ..Default::default() 1277 + }), 1278 + ); 1279 + map 1280 + }, 1281 + ..Default::default() 1282 + }), 1283 + ); 1284 + map 1285 + }, 1286 + ..Default::default() 1287 + } 1288 + } 1289 + 1290 + pub mod label_value_definition_state { 1291 + 1292 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1293 + #[allow(unused)] 1294 + use ::core::marker::PhantomData; 1295 + mod sealed { 1296 + pub trait Sealed {} 1297 + } 1298 + /// State trait tracking which required fields have been set 1299 + pub trait State: sealed::Sealed { 1300 + type Identifier; 1301 + type Locales; 1302 + type Severity; 1303 + type Blurs; 1304 + } 1305 + /// Empty state - all required fields are unset 1306 + pub struct Empty(()); 1307 + impl sealed::Sealed for Empty {} 1308 + impl State for Empty { 1309 + type Identifier = Unset; 1310 + type Locales = Unset; 1311 + type Severity = Unset; 1312 + type Blurs = Unset; 1313 + } 1314 + ///State transition - sets the `identifier` field to Set 1315 + pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>); 1316 + impl<St: State> sealed::Sealed for SetIdentifier<St> {} 1317 + impl<St: State> State for SetIdentifier<St> { 1318 + type Identifier = Set<members::identifier>; 1319 + type Locales = St::Locales; 1320 + type Severity = St::Severity; 1321 + type Blurs = St::Blurs; 1322 + } 1323 + ///State transition - sets the `locales` field to Set 1324 + pub struct SetLocales<St: State = Empty>(PhantomData<fn() -> St>); 1325 + impl<St: State> sealed::Sealed for SetLocales<St> {} 1326 + impl<St: State> State for SetLocales<St> { 1327 + type Identifier = St::Identifier; 1328 + type Locales = Set<members::locales>; 1329 + type Severity = St::Severity; 1330 + type Blurs = St::Blurs; 1331 + } 1332 + ///State transition - sets the `severity` field to Set 1333 + pub struct SetSeverity<St: State = Empty>(PhantomData<fn() -> St>); 1334 + impl<St: State> sealed::Sealed for SetSeverity<St> {} 1335 + impl<St: State> State for SetSeverity<St> { 1336 + type Identifier = St::Identifier; 1337 + type Locales = St::Locales; 1338 + type Severity = Set<members::severity>; 1339 + type Blurs = St::Blurs; 1340 + } 1341 + ///State transition - sets the `blurs` field to Set 1342 + pub struct SetBlurs<St: State = Empty>(PhantomData<fn() -> St>); 1343 + impl<St: State> sealed::Sealed for SetBlurs<St> {} 1344 + impl<St: State> State for SetBlurs<St> { 1345 + type Identifier = St::Identifier; 1346 + type Locales = St::Locales; 1347 + type Severity = St::Severity; 1348 + type Blurs = Set<members::blurs>; 1349 + } 1350 + /// Marker types for field names 1351 + #[allow(non_camel_case_types)] 1352 + pub mod members { 1353 + ///Marker type for the `identifier` field 1354 + pub struct identifier(()); 1355 + ///Marker type for the `locales` field 1356 + pub struct locales(()); 1357 + ///Marker type for the `severity` field 1358 + pub struct severity(()); 1359 + ///Marker type for the `blurs` field 1360 + pub struct blurs(()); 1361 + } 1362 + } 1363 + 1364 + /// Builder for constructing an instance of this type. 1365 + pub struct LabelValueDefinitionBuilder< 1366 + S: BosStr, 1367 + St: label_value_definition_state::State, 1368 + > { 1369 + _state: PhantomData<fn() -> St>, 1370 + _fields: ( 1371 + Option<bool>, 1372 + Option<LabelValueDefinitionBlurs<S>>, 1373 + Option<LabelValueDefinitionDefaultSetting<S>>, 1374 + Option<S>, 1375 + Option<Vec<label::LabelValueDefinitionStrings<S>>>, 1376 + Option<LabelValueDefinitionSeverity<S>>, 1377 + ), 1378 + _type: PhantomData<fn() -> S>, 1379 + } 1380 + 1381 + impl<S: BosStr> LabelValueDefinition<S> { 1382 + /// Create a new builder for this type. 1383 + pub fn new() -> LabelValueDefinitionBuilder<S, label_value_definition_state::Empty> { 1384 + LabelValueDefinitionBuilder::new() 1385 + } 1386 + } 1387 + 1388 + impl<S: BosStr> LabelValueDefinitionBuilder<S, label_value_definition_state::Empty> { 1389 + /// Create a new builder with all fields unset. 1390 + pub fn new() -> Self { 1391 + LabelValueDefinitionBuilder { 1392 + _state: PhantomData, 1393 + _fields: (None, None, None, None, None, None), 1394 + _type: PhantomData, 1395 + } 1396 + } 1397 + } 1398 + 1399 + impl< 1400 + S: BosStr, 1401 + St: label_value_definition_state::State, 1402 + > LabelValueDefinitionBuilder<S, St> { 1403 + /// Set the `adultOnly` field (optional) 1404 + pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self { 1405 + self._fields.0 = value.into(); 1406 + self 1407 + } 1408 + /// Set the `adultOnly` field to an Option value (optional) 1409 + pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self { 1410 + self._fields.0 = value; 1411 + self 1412 + } 1413 + } 1414 + 1415 + impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St> 1416 + where 1417 + St: label_value_definition_state::State, 1418 + St::Blurs: label_value_definition_state::IsUnset, 1419 + { 1420 + /// Set the `blurs` field (required) 1421 + pub fn blurs( 1422 + mut self, 1423 + value: impl Into<LabelValueDefinitionBlurs<S>>, 1424 + ) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetBlurs<St>> { 1425 + self._fields.1 = Option::Some(value.into()); 1426 + LabelValueDefinitionBuilder { 1427 + _state: PhantomData, 1428 + _fields: self._fields, 1429 + _type: PhantomData, 1430 + } 1431 + } 1432 + } 1433 + 1434 + impl< 1435 + S: BosStr, 1436 + St: label_value_definition_state::State, 1437 + > LabelValueDefinitionBuilder<S, St> { 1438 + /// Set the `defaultSetting` field (optional) 1439 + pub fn default_setting( 1440 + mut self, 1441 + value: impl Into<Option<LabelValueDefinitionDefaultSetting<S>>>, 1442 + ) -> Self { 1443 + self._fields.2 = value.into(); 1444 + self 1445 + } 1446 + /// Set the `defaultSetting` field to an Option value (optional) 1447 + pub fn maybe_default_setting( 1448 + mut self, 1449 + value: Option<LabelValueDefinitionDefaultSetting<S>>, 1450 + ) -> Self { 1451 + self._fields.2 = value; 1452 + self 1453 + } 1454 + } 1455 + 1456 + impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St> 1457 + where 1458 + St: label_value_definition_state::State, 1459 + St::Identifier: label_value_definition_state::IsUnset, 1460 + { 1461 + /// Set the `identifier` field (required) 1462 + pub fn identifier( 1463 + mut self, 1464 + value: impl Into<S>, 1465 + ) -> LabelValueDefinitionBuilder< 1466 + S, 1467 + label_value_definition_state::SetIdentifier<St>, 1468 + > { 1469 + self._fields.3 = Option::Some(value.into()); 1470 + LabelValueDefinitionBuilder { 1471 + _state: PhantomData, 1472 + _fields: self._fields, 1473 + _type: PhantomData, 1474 + } 1475 + } 1476 + } 1477 + 1478 + impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St> 1479 + where 1480 + St: label_value_definition_state::State, 1481 + St::Locales: label_value_definition_state::IsUnset, 1482 + { 1483 + /// Set the `locales` field (required) 1484 + pub fn locales( 1485 + mut self, 1486 + value: impl Into<Vec<label::LabelValueDefinitionStrings<S>>>, 1487 + ) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetLocales<St>> { 1488 + self._fields.4 = Option::Some(value.into()); 1489 + LabelValueDefinitionBuilder { 1490 + _state: PhantomData, 1491 + _fields: self._fields, 1492 + _type: PhantomData, 1493 + } 1494 + } 1495 + } 1496 + 1497 + impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St> 1498 + where 1499 + St: label_value_definition_state::State, 1500 + St::Severity: label_value_definition_state::IsUnset, 1501 + { 1502 + /// Set the `severity` field (required) 1503 + pub fn severity( 1504 + mut self, 1505 + value: impl Into<LabelValueDefinitionSeverity<S>>, 1506 + ) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetSeverity<St>> { 1507 + self._fields.5 = Option::Some(value.into()); 1508 + LabelValueDefinitionBuilder { 1509 + _state: PhantomData, 1510 + _fields: self._fields, 1511 + _type: PhantomData, 1512 + } 1513 + } 1514 + } 1515 + 1516 + impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St> 1517 + where 1518 + St: label_value_definition_state::State, 1519 + St::Identifier: label_value_definition_state::IsSet, 1520 + St::Locales: label_value_definition_state::IsSet, 1521 + St::Severity: label_value_definition_state::IsSet, 1522 + St::Blurs: label_value_definition_state::IsSet, 1523 + { 1524 + /// Build the final struct. 1525 + pub fn build(self) -> LabelValueDefinition<S> { 1526 + LabelValueDefinition { 1527 + adult_only: self._fields.0, 1528 + blurs: self._fields.1.unwrap(), 1529 + default_setting: self._fields.2, 1530 + identifier: self._fields.3.unwrap(), 1531 + locales: self._fields.4.unwrap(), 1532 + severity: self._fields.5.unwrap(), 1533 + extra_data: Default::default(), 1534 + } 1535 + } 1536 + /// Build the final struct with custom extra_data. 1537 + pub fn build_with_data( 1538 + self, 1539 + extra_data: BTreeMap<SmolStr, Data<S>>, 1540 + ) -> LabelValueDefinition<S> { 1541 + LabelValueDefinition { 1542 + adult_only: self._fields.0, 1543 + blurs: self._fields.1.unwrap(), 1544 + default_setting: self._fields.2, 1545 + identifier: self._fields.3.unwrap(), 1546 + locales: self._fields.4.unwrap(), 1547 + severity: self._fields.5.unwrap(), 1548 + extra_data: Some(extra_data), 1549 + } 1550 + } 1551 + } 1552 + 1553 + pub mod label_value_definition_strings_state { 1554 + 1555 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1556 + #[allow(unused)] 1557 + use ::core::marker::PhantomData; 1558 + mod sealed { 1559 + pub trait Sealed {} 1560 + } 1561 + /// State trait tracking which required fields have been set 1562 + pub trait State: sealed::Sealed { 1563 + type Description; 1564 + type Lang; 1565 + type Name; 1566 + } 1567 + /// Empty state - all required fields are unset 1568 + pub struct Empty(()); 1569 + impl sealed::Sealed for Empty {} 1570 + impl State for Empty { 1571 + type Description = Unset; 1572 + type Lang = Unset; 1573 + type Name = Unset; 1574 + } 1575 + ///State transition - sets the `description` field to Set 1576 + pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>); 1577 + impl<St: State> sealed::Sealed for SetDescription<St> {} 1578 + impl<St: State> State for SetDescription<St> { 1579 + type Description = Set<members::description>; 1580 + type Lang = St::Lang; 1581 + type Name = St::Name; 1582 + } 1583 + ///State transition - sets the `lang` field to Set 1584 + pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>); 1585 + impl<St: State> sealed::Sealed for SetLang<St> {} 1586 + impl<St: State> State for SetLang<St> { 1587 + type Description = St::Description; 1588 + type Lang = Set<members::lang>; 1589 + type Name = St::Name; 1590 + } 1591 + ///State transition - sets the `name` field to Set 1592 + pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>); 1593 + impl<St: State> sealed::Sealed for SetName<St> {} 1594 + impl<St: State> State for SetName<St> { 1595 + type Description = St::Description; 1596 + type Lang = St::Lang; 1597 + type Name = Set<members::name>; 1598 + } 1599 + /// Marker types for field names 1600 + #[allow(non_camel_case_types)] 1601 + pub mod members { 1602 + ///Marker type for the `description` field 1603 + pub struct description(()); 1604 + ///Marker type for the `lang` field 1605 + pub struct lang(()); 1606 + ///Marker type for the `name` field 1607 + pub struct name(()); 1608 + } 1609 + } 1610 + 1611 + /// Builder for constructing an instance of this type. 1612 + pub struct LabelValueDefinitionStringsBuilder< 1613 + S: BosStr, 1614 + St: label_value_definition_strings_state::State, 1615 + > { 1616 + _state: PhantomData<fn() -> St>, 1617 + _fields: (Option<S>, Option<Language>, Option<S>), 1618 + _type: PhantomData<fn() -> S>, 1619 + } 1620 + 1621 + impl<S: BosStr> LabelValueDefinitionStrings<S> { 1622 + /// Create a new builder for this type. 1623 + pub fn new() -> LabelValueDefinitionStringsBuilder< 1624 + S, 1625 + label_value_definition_strings_state::Empty, 1626 + > { 1627 + LabelValueDefinitionStringsBuilder::new() 1628 + } 1629 + } 1630 + 1631 + impl< 1632 + S: BosStr, 1633 + > LabelValueDefinitionStringsBuilder<S, label_value_definition_strings_state::Empty> { 1634 + /// Create a new builder with all fields unset. 1635 + pub fn new() -> Self { 1636 + LabelValueDefinitionStringsBuilder { 1637 + _state: PhantomData, 1638 + _fields: (None, None, None), 1639 + _type: PhantomData, 1640 + } 1641 + } 1642 + } 1643 + 1644 + impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1645 + where 1646 + St: label_value_definition_strings_state::State, 1647 + St::Description: label_value_definition_strings_state::IsUnset, 1648 + { 1649 + /// Set the `description` field (required) 1650 + pub fn description( 1651 + mut self, 1652 + value: impl Into<S>, 1653 + ) -> LabelValueDefinitionStringsBuilder< 1654 + S, 1655 + label_value_definition_strings_state::SetDescription<St>, 1656 + > { 1657 + self._fields.0 = Option::Some(value.into()); 1658 + LabelValueDefinitionStringsBuilder { 1659 + _state: PhantomData, 1660 + _fields: self._fields, 1661 + _type: PhantomData, 1662 + } 1663 + } 1664 + } 1665 + 1666 + impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1667 + where 1668 + St: label_value_definition_strings_state::State, 1669 + St::Lang: label_value_definition_strings_state::IsUnset, 1670 + { 1671 + /// Set the `lang` field (required) 1672 + pub fn lang( 1673 + mut self, 1674 + value: impl Into<Language>, 1675 + ) -> LabelValueDefinitionStringsBuilder< 1676 + S, 1677 + label_value_definition_strings_state::SetLang<St>, 1678 + > { 1679 + self._fields.1 = Option::Some(value.into()); 1680 + LabelValueDefinitionStringsBuilder { 1681 + _state: PhantomData, 1682 + _fields: self._fields, 1683 + _type: PhantomData, 1684 + } 1685 + } 1686 + } 1687 + 1688 + impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1689 + where 1690 + St: label_value_definition_strings_state::State, 1691 + St::Name: label_value_definition_strings_state::IsUnset, 1692 + { 1693 + /// Set the `name` field (required) 1694 + pub fn name( 1695 + mut self, 1696 + value: impl Into<S>, 1697 + ) -> LabelValueDefinitionStringsBuilder< 1698 + S, 1699 + label_value_definition_strings_state::SetName<St>, 1700 + > { 1701 + self._fields.2 = Option::Some(value.into()); 1702 + LabelValueDefinitionStringsBuilder { 1703 + _state: PhantomData, 1704 + _fields: self._fields, 1705 + _type: PhantomData, 1706 + } 1707 + } 1708 + } 1709 + 1710 + impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St> 1711 + where 1712 + St: label_value_definition_strings_state::State, 1713 + St::Description: label_value_definition_strings_state::IsSet, 1714 + St::Lang: label_value_definition_strings_state::IsSet, 1715 + St::Name: label_value_definition_strings_state::IsSet, 1716 + { 1717 + /// Build the final struct. 1718 + pub fn build(self) -> LabelValueDefinitionStrings<S> { 1719 + LabelValueDefinitionStrings { 1720 + description: self._fields.0.unwrap(), 1721 + lang: self._fields.1.unwrap(), 1722 + name: self._fields.2.unwrap(), 1723 + extra_data: Default::default(), 1724 + } 1725 + } 1726 + /// Build the final struct with custom extra_data. 1727 + pub fn build_with_data( 1728 + self, 1729 + extra_data: BTreeMap<SmolStr, Data<S>>, 1730 + ) -> LabelValueDefinitionStrings<S> { 1731 + LabelValueDefinitionStrings { 1732 + description: self._fields.0.unwrap(), 1733 + lang: self._fields.1.unwrap(), 1734 + name: self._fields.2.unwrap(), 1735 + extra_data: Some(extra_data), 1736 + } 1737 + } 1738 + } 1739 + 1740 + pub mod self_labels_state { 1741 + 1742 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1743 + #[allow(unused)] 1744 + use ::core::marker::PhantomData; 1745 + mod sealed { 1746 + pub trait Sealed {} 1747 + } 1748 + /// State trait tracking which required fields have been set 1749 + pub trait State: sealed::Sealed { 1750 + type Values; 1751 + } 1752 + /// Empty state - all required fields are unset 1753 + pub struct Empty(()); 1754 + impl sealed::Sealed for Empty {} 1755 + impl State for Empty { 1756 + type Values = Unset; 1757 + } 1758 + ///State transition - sets the `values` field to Set 1759 + pub struct SetValues<St: State = Empty>(PhantomData<fn() -> St>); 1760 + impl<St: State> sealed::Sealed for SetValues<St> {} 1761 + impl<St: State> State for SetValues<St> { 1762 + type Values = Set<members::values>; 1763 + } 1764 + /// Marker types for field names 1765 + #[allow(non_camel_case_types)] 1766 + pub mod members { 1767 + ///Marker type for the `values` field 1768 + pub struct values(()); 1769 + } 1770 + } 1771 + 1772 + /// Builder for constructing an instance of this type. 1773 + pub struct SelfLabelsBuilder<S: BosStr, St: self_labels_state::State> { 1774 + _state: PhantomData<fn() -> St>, 1775 + _fields: (Option<Vec<label::SelfLabel<S>>>,), 1776 + _type: PhantomData<fn() -> S>, 1777 + } 1778 + 1779 + impl<S: BosStr> SelfLabels<S> { 1780 + /// Create a new builder for this type. 1781 + pub fn new() -> SelfLabelsBuilder<S, self_labels_state::Empty> { 1782 + SelfLabelsBuilder::new() 1783 + } 1784 + } 1785 + 1786 + impl<S: BosStr> SelfLabelsBuilder<S, self_labels_state::Empty> { 1787 + /// Create a new builder with all fields unset. 1788 + pub fn new() -> Self { 1789 + SelfLabelsBuilder { 1790 + _state: PhantomData, 1791 + _fields: (None,), 1792 + _type: PhantomData, 1793 + } 1794 + } 1795 + } 1796 + 1797 + impl<S: BosStr, St> SelfLabelsBuilder<S, St> 1798 + where 1799 + St: self_labels_state::State, 1800 + St::Values: self_labels_state::IsUnset, 1801 + { 1802 + /// Set the `values` field (required) 1803 + pub fn values( 1804 + mut self, 1805 + value: impl Into<Vec<label::SelfLabel<S>>>, 1806 + ) -> SelfLabelsBuilder<S, self_labels_state::SetValues<St>> { 1807 + self._fields.0 = Option::Some(value.into()); 1808 + SelfLabelsBuilder { 1809 + _state: PhantomData, 1810 + _fields: self._fields, 1811 + _type: PhantomData, 1812 + } 1813 + } 1814 + } 1815 + 1816 + impl<S: BosStr, St> SelfLabelsBuilder<S, St> 1817 + where 1818 + St: self_labels_state::State, 1819 + St::Values: self_labels_state::IsSet, 1820 + { 1821 + /// Build the final struct. 1822 + pub fn build(self) -> SelfLabels<S> { 1823 + SelfLabels { 1824 + values: self._fields.0.unwrap(), 1825 + extra_data: Default::default(), 1826 + } 1827 + } 1828 + /// Build the final struct with custom extra_data. 1829 + pub fn build_with_data( 1830 + self, 1831 + extra_data: BTreeMap<SmolStr, Data<S>>, 1832 + ) -> SelfLabels<S> { 1833 + SelfLabels { 1834 + values: self._fields.0.unwrap(), 1835 + extra_data: Some(extra_data), 1836 + } 1837 + } 1838 + }
+6
crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/repo.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod strong_ref;
+228
crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/repo/strong_ref.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: com.atproto.repo.strongRef 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::string::{AtUri, Cid}; 19 + use jacquard_common::types::value::Data; 20 + use jacquard_derive::IntoStatic; 21 + use jacquard_lexicon::lexicon::LexiconDoc; 22 + use jacquard_lexicon::schema::LexiconSchema; 23 + 24 + #[allow(unused_imports)] 25 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 26 + use serde::{Serialize, Deserialize}; 27 + 28 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 29 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 30 + pub struct StrongRef<S: BosStr = DefaultStr> { 31 + pub cid: Cid<S>, 32 + pub uri: AtUri<S>, 33 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 34 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 35 + } 36 + 37 + impl<S: BosStr> LexiconSchema for StrongRef<S> { 38 + fn nsid() -> &'static str { 39 + "com.atproto.repo.strongRef" 40 + } 41 + fn def_name() -> &'static str { 42 + "main" 43 + } 44 + fn lexicon_doc() -> LexiconDoc<'static> { 45 + lexicon_doc_com_atproto_repo_strongRef() 46 + } 47 + fn validate(&self) -> Result<(), ConstraintError> { 48 + Ok(()) 49 + } 50 + } 51 + 52 + pub mod strong_ref_state { 53 + 54 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 55 + #[allow(unused)] 56 + use ::core::marker::PhantomData; 57 + mod sealed { 58 + pub trait Sealed {} 59 + } 60 + /// State trait tracking which required fields have been set 61 + pub trait State: sealed::Sealed { 62 + type Uri; 63 + type Cid; 64 + } 65 + /// Empty state - all required fields are unset 66 + pub struct Empty(()); 67 + impl sealed::Sealed for Empty {} 68 + impl State for Empty { 69 + type Uri = Unset; 70 + type Cid = Unset; 71 + } 72 + ///State transition - sets the `uri` field to Set 73 + pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>); 74 + impl<St: State> sealed::Sealed for SetUri<St> {} 75 + impl<St: State> State for SetUri<St> { 76 + type Uri = Set<members::uri>; 77 + type Cid = St::Cid; 78 + } 79 + ///State transition - sets the `cid` field to Set 80 + pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>); 81 + impl<St: State> sealed::Sealed for SetCid<St> {} 82 + impl<St: State> State for SetCid<St> { 83 + type Uri = St::Uri; 84 + type Cid = Set<members::cid>; 85 + } 86 + /// Marker types for field names 87 + #[allow(non_camel_case_types)] 88 + pub mod members { 89 + ///Marker type for the `uri` field 90 + pub struct uri(()); 91 + ///Marker type for the `cid` field 92 + pub struct cid(()); 93 + } 94 + } 95 + 96 + /// Builder for constructing an instance of this type. 97 + pub struct StrongRefBuilder<S: BosStr, St: strong_ref_state::State> { 98 + _state: PhantomData<fn() -> St>, 99 + _fields: (Option<Cid<S>>, Option<AtUri<S>>), 100 + _type: PhantomData<fn() -> S>, 101 + } 102 + 103 + impl<S: BosStr> StrongRef<S> { 104 + /// Create a new builder for this type. 105 + pub fn new() -> StrongRefBuilder<S, strong_ref_state::Empty> { 106 + StrongRefBuilder::new() 107 + } 108 + } 109 + 110 + impl<S: BosStr> StrongRefBuilder<S, strong_ref_state::Empty> { 111 + /// Create a new builder with all fields unset. 112 + pub fn new() -> Self { 113 + StrongRefBuilder { 114 + _state: PhantomData, 115 + _fields: (None, None), 116 + _type: PhantomData, 117 + } 118 + } 119 + } 120 + 121 + impl<S: BosStr, St> StrongRefBuilder<S, St> 122 + where 123 + St: strong_ref_state::State, 124 + St::Cid: strong_ref_state::IsUnset, 125 + { 126 + /// Set the `cid` field (required) 127 + pub fn cid( 128 + mut self, 129 + value: impl Into<Cid<S>>, 130 + ) -> StrongRefBuilder<S, strong_ref_state::SetCid<St>> { 131 + self._fields.0 = Option::Some(value.into()); 132 + StrongRefBuilder { 133 + _state: PhantomData, 134 + _fields: self._fields, 135 + _type: PhantomData, 136 + } 137 + } 138 + } 139 + 140 + impl<S: BosStr, St> StrongRefBuilder<S, St> 141 + where 142 + St: strong_ref_state::State, 143 + St::Uri: strong_ref_state::IsUnset, 144 + { 145 + /// Set the `uri` field (required) 146 + pub fn uri( 147 + mut self, 148 + value: impl Into<AtUri<S>>, 149 + ) -> StrongRefBuilder<S, strong_ref_state::SetUri<St>> { 150 + self._fields.1 = Option::Some(value.into()); 151 + StrongRefBuilder { 152 + _state: PhantomData, 153 + _fields: self._fields, 154 + _type: PhantomData, 155 + } 156 + } 157 + } 158 + 159 + impl<S: BosStr, St> StrongRefBuilder<S, St> 160 + where 161 + St: strong_ref_state::State, 162 + St::Uri: strong_ref_state::IsSet, 163 + St::Cid: strong_ref_state::IsSet, 164 + { 165 + /// Build the final struct. 166 + pub fn build(self) -> StrongRef<S> { 167 + StrongRef { 168 + cid: self._fields.0.unwrap(), 169 + uri: self._fields.1.unwrap(), 170 + extra_data: Default::default(), 171 + } 172 + } 173 + /// Build the final struct with custom extra_data. 174 + pub fn build_with_data( 175 + self, 176 + extra_data: BTreeMap<SmolStr, Data<S>>, 177 + ) -> StrongRef<S> { 178 + StrongRef { 179 + cid: self._fields.0.unwrap(), 180 + uri: self._fields.1.unwrap(), 181 + extra_data: Some(extra_data), 182 + } 183 + } 184 + } 185 + 186 + fn lexicon_doc_com_atproto_repo_strongRef() -> LexiconDoc<'static> { 187 + #[allow(unused_imports)] 188 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 189 + use jacquard_lexicon::lexicon::*; 190 + use alloc::collections::BTreeMap; 191 + LexiconDoc { 192 + lexicon: Lexicon::Lexicon1, 193 + id: CowStr::new_static("com.atproto.repo.strongRef"), 194 + defs: { 195 + let mut map = BTreeMap::new(); 196 + map.insert( 197 + SmolStr::new_static("main"), 198 + LexUserType::Object(LexObject { 199 + required: Some( 200 + vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")], 201 + ), 202 + properties: { 203 + #[allow(unused_mut)] 204 + let mut map = BTreeMap::new(); 205 + map.insert( 206 + SmolStr::new_static("cid"), 207 + LexObjectProperty::String(LexString { 208 + format: Some(LexStringFormat::Cid), 209 + ..Default::default() 210 + }), 211 + ); 212 + map.insert( 213 + SmolStr::new_static("uri"), 214 + LexObjectProperty::String(LexString { 215 + format: Some(LexStringFormat::AtUri), 216 + ..Default::default() 217 + }), 218 + ); 219 + map 220 + }, 221 + ..Default::default() 222 + }), 223 + ); 224 + map 225 + }, 226 + ..Default::default() 227 + } 228 + }
+30
crates/jacquard-codegen-tests/src/generated/pretty/lib.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + extern crate alloc; 7 + 8 + #[cfg(feature = "app_bsky")] 9 + pub mod app_bsky; 10 + pub mod builder_types; 11 + 12 + 13 + #[cfg(feature = "com_atproto")] 14 + pub mod com_atproto; 15 + 16 + 17 + #[cfg(feature = "test_collision")] 18 + pub mod test_collision; 19 + 20 + 21 + #[cfg(feature = "test_ns1")] 22 + pub mod test_ns1; 23 + 24 + 25 + #[cfg(feature = "test_ns2")] 26 + pub mod test_ns2; 27 + 28 + 29 + #[cfg(feature = "test_ns3")] 30 + pub mod test_ns3;
+8
crates/jacquard-codegen-tests/src/generated/pretty/test_collision.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod collection; 7 + pub mod did; 8 + pub mod option;
+409
crates/jacquard-codegen-tests/src/generated/pretty/test_collision/collection.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.collision.collection 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::collection::RecordError; 19 + use jacquard_common::types::string::{AtUri, Cid, Datetime}; 20 + use jacquard_common::types::uri::{RecordUri, UriError}; 21 + use jacquard_common::types::value::Data; 22 + use jacquard_common::xrpc::XrpcResp; 23 + use jacquard_derive::{IntoStatic, lexicon}; 24 + use jacquard_lexicon::lexicon::LexiconDoc; 25 + use jacquard_lexicon::schema::LexiconSchema; 26 + 27 + #[allow(unused_imports)] 28 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 29 + use serde::{Serialize, Deserialize}; 30 + use crate::pretty::test_collision::collection; 31 + /// A locally-defined type named Collection that collides with the trait import. 32 + 33 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 34 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 35 + pub struct Collection<S: BosStr = DefaultStr> { 36 + #[serde(skip_serializing_if = "Option::is_none")] 37 + pub count: Option<i64>, 38 + pub label: S, 39 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 40 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 41 + } 42 + 43 + /// A record that itself references the Collection trait via its NSID. 44 + 45 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 46 + #[serde( 47 + rename_all = "camelCase", 48 + rename = "test.collision.collection", 49 + tag = "$type", 50 + bound(deserialize = "S: Deserialize<'de> + BosStr") 51 + )] 52 + pub struct CollectionRecord<S: BosStr = DefaultStr> { 53 + #[serde(skip_serializing_if = "Option::is_none")] 54 + pub created_at: Option<Datetime>, 55 + pub items: Vec<collection::Collection<S>>, 56 + pub name: S, 57 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 58 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 59 + } 60 + 61 + /// Typed wrapper for GetRecord response with this collection's record type. 62 + 63 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 64 + #[serde(rename_all = "camelCase")] 65 + pub struct CollectionRecordGetRecordOutput<S: BosStr = DefaultStr> { 66 + #[serde(skip_serializing_if = "Option::is_none")] 67 + pub cid: Option<Cid<S>>, 68 + pub uri: AtUri<S>, 69 + pub value: CollectionRecord<S>, 70 + } 71 + 72 + impl<S: BosStr> CollectionRecord<S> { 73 + pub fn uri(uri: S) -> Result<RecordUri<S, CollectionRecordRecord>, UriError> { 74 + RecordUri::try_from_uri(AtUri::new(uri)?) 75 + } 76 + } 77 + 78 + impl<S: BosStr> LexiconSchema for Collection<S> { 79 + fn nsid() -> &'static str { 80 + "test.collision.collection" 81 + } 82 + fn def_name() -> &'static str { 83 + "collection" 84 + } 85 + fn lexicon_doc() -> LexiconDoc<'static> { 86 + lexicon_doc_test_collision_collection() 87 + } 88 + fn validate(&self) -> Result<(), ConstraintError> { 89 + if let Some(ref value) = self.count { 90 + if *value < 0i64 { 91 + return Err(ConstraintError::Minimum { 92 + path: ValidationPath::from_field("count"), 93 + min: 0i64, 94 + actual: *value, 95 + }); 96 + } 97 + } 98 + { 99 + let value = &self.label; 100 + #[allow(unused_comparisons)] 101 + if <str>::len(value.as_ref()) > 100usize { 102 + return Err(ConstraintError::MaxLength { 103 + path: ValidationPath::from_field("label"), 104 + max: 100usize, 105 + actual: <str>::len(value.as_ref()), 106 + }); 107 + } 108 + } 109 + Ok(()) 110 + } 111 + } 112 + 113 + /// Marker type for deserializing records from this collection. 114 + 115 + #[derive(Debug, Serialize, Deserialize)] 116 + pub struct CollectionRecordRecord; 117 + impl XrpcResp for CollectionRecordRecord { 118 + const NSID: &'static str = "test.collision.collection"; 119 + const ENCODING: &'static str = "application/json"; 120 + type Output<S: BosStr> = CollectionRecordGetRecordOutput<S>; 121 + type Err = RecordError; 122 + } 123 + 124 + impl<S: BosStr> From<CollectionRecordGetRecordOutput<S>> for CollectionRecord<S> { 125 + fn from(output: CollectionRecordGetRecordOutput<S>) -> Self { 126 + output.value 127 + } 128 + } 129 + 130 + impl<S: BosStr> jacquard_common::types::collection::Collection for CollectionRecord<S> { 131 + const NSID: &'static str = "test.collision.collection"; 132 + type Record = CollectionRecordRecord; 133 + } 134 + 135 + impl jacquard_common::types::collection::Collection for CollectionRecordRecord { 136 + const NSID: &'static str = "test.collision.collection"; 137 + type Record = CollectionRecordRecord; 138 + } 139 + 140 + impl<S: BosStr> LexiconSchema for CollectionRecord<S> { 141 + fn nsid() -> &'static str { 142 + "test.collision.collection" 143 + } 144 + fn def_name() -> &'static str { 145 + "main" 146 + } 147 + fn lexicon_doc() -> LexiconDoc<'static> { 148 + lexicon_doc_test_collision_collection() 149 + } 150 + fn validate(&self) -> Result<(), ConstraintError> { 151 + { 152 + let value = &self.name; 153 + #[allow(unused_comparisons)] 154 + if <str>::len(value.as_ref()) > 256usize { 155 + return Err(ConstraintError::MaxLength { 156 + path: ValidationPath::from_field("name"), 157 + max: 256usize, 158 + actual: <str>::len(value.as_ref()), 159 + }); 160 + } 161 + } 162 + Ok(()) 163 + } 164 + } 165 + 166 + fn lexicon_doc_test_collision_collection() -> LexiconDoc<'static> { 167 + #[allow(unused_imports)] 168 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 169 + use jacquard_lexicon::lexicon::*; 170 + use alloc::collections::BTreeMap; 171 + LexiconDoc { 172 + lexicon: Lexicon::Lexicon1, 173 + id: CowStr::new_static("test.collision.collection"), 174 + defs: { 175 + let mut map = BTreeMap::new(); 176 + map.insert( 177 + SmolStr::new_static("collection"), 178 + LexUserType::Object(LexObject { 179 + description: Some( 180 + CowStr::new_static( 181 + "A locally-defined type named Collection that collides with the trait import.", 182 + ), 183 + ), 184 + required: Some(vec![SmolStr::new_static("label")]), 185 + properties: { 186 + #[allow(unused_mut)] 187 + let mut map = BTreeMap::new(); 188 + map.insert( 189 + SmolStr::new_static("count"), 190 + LexObjectProperty::Integer(LexInteger { 191 + minimum: Some(0i64), 192 + ..Default::default() 193 + }), 194 + ); 195 + map.insert( 196 + SmolStr::new_static("label"), 197 + LexObjectProperty::String(LexString { 198 + max_length: Some(100usize), 199 + ..Default::default() 200 + }), 201 + ); 202 + map 203 + }, 204 + ..Default::default() 205 + }), 206 + ); 207 + map.insert( 208 + SmolStr::new_static("main"), 209 + LexUserType::Record(LexRecord { 210 + description: Some( 211 + CowStr::new_static( 212 + "A record that itself references the Collection trait via its NSID.", 213 + ), 214 + ), 215 + key: Some(CowStr::new_static("tid")), 216 + record: LexRecordRecord::Object(LexObject { 217 + required: Some( 218 + vec![ 219 + SmolStr::new_static("name"), SmolStr::new_static("items") 220 + ], 221 + ), 222 + properties: { 223 + #[allow(unused_mut)] 224 + let mut map = BTreeMap::new(); 225 + map.insert( 226 + SmolStr::new_static("createdAt"), 227 + LexObjectProperty::String(LexString { 228 + format: Some(LexStringFormat::Datetime), 229 + ..Default::default() 230 + }), 231 + ); 232 + map.insert( 233 + SmolStr::new_static("items"), 234 + LexObjectProperty::Array(LexArray { 235 + items: LexArrayItem::Ref(LexRef { 236 + r#ref: CowStr::new_static("#collection"), 237 + ..Default::default() 238 + }), 239 + ..Default::default() 240 + }), 241 + ); 242 + map.insert( 243 + SmolStr::new_static("name"), 244 + LexObjectProperty::String(LexString { 245 + max_length: Some(256usize), 246 + ..Default::default() 247 + }), 248 + ); 249 + map 250 + }, 251 + ..Default::default() 252 + }), 253 + ..Default::default() 254 + }), 255 + ); 256 + map 257 + }, 258 + ..Default::default() 259 + } 260 + } 261 + 262 + pub mod collection_record_state { 263 + 264 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 265 + #[allow(unused)] 266 + use ::core::marker::PhantomData; 267 + mod sealed { 268 + pub trait Sealed {} 269 + } 270 + /// State trait tracking which required fields have been set 271 + pub trait State: sealed::Sealed { 272 + type Items; 273 + type Name; 274 + } 275 + /// Empty state - all required fields are unset 276 + pub struct Empty(()); 277 + impl sealed::Sealed for Empty {} 278 + impl State for Empty { 279 + type Items = Unset; 280 + type Name = Unset; 281 + } 282 + ///State transition - sets the `items` field to Set 283 + pub struct SetItems<St: State = Empty>(PhantomData<fn() -> St>); 284 + impl<St: State> sealed::Sealed for SetItems<St> {} 285 + impl<St: State> State for SetItems<St> { 286 + type Items = Set<members::items>; 287 + type Name = St::Name; 288 + } 289 + ///State transition - sets the `name` field to Set 290 + pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>); 291 + impl<St: State> sealed::Sealed for SetName<St> {} 292 + impl<St: State> State for SetName<St> { 293 + type Items = St::Items; 294 + type Name = Set<members::name>; 295 + } 296 + /// Marker types for field names 297 + #[allow(non_camel_case_types)] 298 + pub mod members { 299 + ///Marker type for the `items` field 300 + pub struct items(()); 301 + ///Marker type for the `name` field 302 + pub struct name(()); 303 + } 304 + } 305 + 306 + /// Builder for constructing an instance of this type. 307 + pub struct CollectionRecordBuilder<S: BosStr, St: collection_record_state::State> { 308 + _state: PhantomData<fn() -> St>, 309 + _fields: (Option<Datetime>, Option<Vec<collection::Collection<S>>>, Option<S>), 310 + _type: PhantomData<fn() -> S>, 311 + } 312 + 313 + impl<S: BosStr> CollectionRecord<S> { 314 + /// Create a new builder for this type. 315 + pub fn new() -> CollectionRecordBuilder<S, collection_record_state::Empty> { 316 + CollectionRecordBuilder::new() 317 + } 318 + } 319 + 320 + impl<S: BosStr> CollectionRecordBuilder<S, collection_record_state::Empty> { 321 + /// Create a new builder with all fields unset. 322 + pub fn new() -> Self { 323 + CollectionRecordBuilder { 324 + _state: PhantomData, 325 + _fields: (None, None, None), 326 + _type: PhantomData, 327 + } 328 + } 329 + } 330 + 331 + impl<S: BosStr, St: collection_record_state::State> CollectionRecordBuilder<S, St> { 332 + /// Set the `createdAt` field (optional) 333 + pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self { 334 + self._fields.0 = value.into(); 335 + self 336 + } 337 + /// Set the `createdAt` field to an Option value (optional) 338 + pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self { 339 + self._fields.0 = value; 340 + self 341 + } 342 + } 343 + 344 + impl<S: BosStr, St> CollectionRecordBuilder<S, St> 345 + where 346 + St: collection_record_state::State, 347 + St::Items: collection_record_state::IsUnset, 348 + { 349 + /// Set the `items` field (required) 350 + pub fn items( 351 + mut self, 352 + value: impl Into<Vec<collection::Collection<S>>>, 353 + ) -> CollectionRecordBuilder<S, collection_record_state::SetItems<St>> { 354 + self._fields.1 = Option::Some(value.into()); 355 + CollectionRecordBuilder { 356 + _state: PhantomData, 357 + _fields: self._fields, 358 + _type: PhantomData, 359 + } 360 + } 361 + } 362 + 363 + impl<S: BosStr, St> CollectionRecordBuilder<S, St> 364 + where 365 + St: collection_record_state::State, 366 + St::Name: collection_record_state::IsUnset, 367 + { 368 + /// Set the `name` field (required) 369 + pub fn name( 370 + mut self, 371 + value: impl Into<S>, 372 + ) -> CollectionRecordBuilder<S, collection_record_state::SetName<St>> { 373 + self._fields.2 = Option::Some(value.into()); 374 + CollectionRecordBuilder { 375 + _state: PhantomData, 376 + _fields: self._fields, 377 + _type: PhantomData, 378 + } 379 + } 380 + } 381 + 382 + impl<S: BosStr, St> CollectionRecordBuilder<S, St> 383 + where 384 + St: collection_record_state::State, 385 + St::Items: collection_record_state::IsSet, 386 + St::Name: collection_record_state::IsSet, 387 + { 388 + /// Build the final struct. 389 + pub fn build(self) -> CollectionRecord<S> { 390 + CollectionRecord { 391 + created_at: self._fields.0, 392 + items: self._fields.1.unwrap(), 393 + name: self._fields.2.unwrap(), 394 + extra_data: Default::default(), 395 + } 396 + } 397 + /// Build the final struct with custom extra_data. 398 + pub fn build_with_data( 399 + self, 400 + extra_data: BTreeMap<SmolStr, Data<S>>, 401 + ) -> CollectionRecord<S> { 402 + CollectionRecord { 403 + created_at: self._fields.0, 404 + items: self._fields.1.unwrap(), 405 + name: self._fields.2.unwrap(), 406 + extra_data: Some(extra_data), 407 + } 408 + } 409 + }
+370
crates/jacquard-codegen-tests/src/generated/pretty/test_collision/did.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.collision.did 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::value::Data; 19 + use jacquard_derive::IntoStatic; 20 + use jacquard_lexicon::lexicon::LexiconDoc; 21 + use jacquard_lexicon::schema::LexiconSchema; 22 + 23 + #[allow(unused_imports)] 24 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 25 + use serde::{Serialize, Deserialize}; 26 + use crate::pretty::test_collision::did; 27 + /// A locally-defined type named Did that collides with the string import. 28 + 29 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 30 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 31 + pub struct Did<S: BosStr = DefaultStr> { 32 + ///The DID method (e.g., plc, web). 33 + pub method: S, 34 + ///The full DID string. 35 + pub value: S, 36 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 37 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 38 + } 39 + 40 + /// An object that also uses a DID-format string field, exercising the collision path. 41 + 42 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 43 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 44 + pub struct DidRecord<S: BosStr = DefaultStr> { 45 + pub identifier: did::Did<S>, 46 + #[serde(skip_serializing_if = "Option::is_none")] 47 + pub label: Option<S>, 48 + ///A field typed as DID format, requiring the Did import but colliding with local Did type. 49 + pub owner: jacquard_common::types::string::Did<S>, 50 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 51 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 52 + } 53 + 54 + impl<S: BosStr> LexiconSchema for Did<S> { 55 + fn nsid() -> &'static str { 56 + "test.collision.did" 57 + } 58 + fn def_name() -> &'static str { 59 + "did" 60 + } 61 + fn lexicon_doc() -> LexiconDoc<'static> { 62 + lexicon_doc_test_collision_did() 63 + } 64 + fn validate(&self) -> Result<(), ConstraintError> { 65 + { 66 + let value = &self.method; 67 + #[allow(unused_comparisons)] 68 + if <str>::len(value.as_ref()) > 50usize { 69 + return Err(ConstraintError::MaxLength { 70 + path: ValidationPath::from_field("method"), 71 + max: 50usize, 72 + actual: <str>::len(value.as_ref()), 73 + }); 74 + } 75 + } 76 + { 77 + let value = &self.value; 78 + #[allow(unused_comparisons)] 79 + if <str>::len(value.as_ref()) > 256usize { 80 + return Err(ConstraintError::MaxLength { 81 + path: ValidationPath::from_field("value"), 82 + max: 256usize, 83 + actual: <str>::len(value.as_ref()), 84 + }); 85 + } 86 + } 87 + Ok(()) 88 + } 89 + } 90 + 91 + impl<S: BosStr> LexiconSchema for DidRecord<S> { 92 + fn nsid() -> &'static str { 93 + "test.collision.did" 94 + } 95 + fn def_name() -> &'static str { 96 + "main" 97 + } 98 + fn lexicon_doc() -> LexiconDoc<'static> { 99 + lexicon_doc_test_collision_did() 100 + } 101 + fn validate(&self) -> Result<(), ConstraintError> { 102 + if let Some(ref value) = self.label { 103 + #[allow(unused_comparisons)] 104 + if <str>::len(value.as_ref()) > 200usize { 105 + return Err(ConstraintError::MaxLength { 106 + path: ValidationPath::from_field("label"), 107 + max: 200usize, 108 + actual: <str>::len(value.as_ref()), 109 + }); 110 + } 111 + } 112 + Ok(()) 113 + } 114 + } 115 + 116 + fn lexicon_doc_test_collision_did() -> LexiconDoc<'static> { 117 + #[allow(unused_imports)] 118 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 119 + use jacquard_lexicon::lexicon::*; 120 + use alloc::collections::BTreeMap; 121 + LexiconDoc { 122 + lexicon: Lexicon::Lexicon1, 123 + id: CowStr::new_static("test.collision.did"), 124 + defs: { 125 + let mut map = BTreeMap::new(); 126 + map.insert( 127 + SmolStr::new_static("did"), 128 + LexUserType::Object(LexObject { 129 + description: Some( 130 + CowStr::new_static( 131 + "A locally-defined type named Did that collides with the string import.", 132 + ), 133 + ), 134 + required: Some( 135 + vec![SmolStr::new_static("method"), SmolStr::new_static("value")], 136 + ), 137 + properties: { 138 + #[allow(unused_mut)] 139 + let mut map = BTreeMap::new(); 140 + map.insert( 141 + SmolStr::new_static("method"), 142 + LexObjectProperty::String(LexString { 143 + description: Some( 144 + CowStr::new_static("The DID method (e.g., plc, web)."), 145 + ), 146 + max_length: Some(50usize), 147 + ..Default::default() 148 + }), 149 + ); 150 + map.insert( 151 + SmolStr::new_static("value"), 152 + LexObjectProperty::String(LexString { 153 + description: Some( 154 + CowStr::new_static("The full DID string."), 155 + ), 156 + max_length: Some(256usize), 157 + ..Default::default() 158 + }), 159 + ); 160 + map 161 + }, 162 + ..Default::default() 163 + }), 164 + ); 165 + map.insert( 166 + SmolStr::new_static("main"), 167 + LexUserType::Object(LexObject { 168 + description: Some( 169 + CowStr::new_static( 170 + "An object that also uses a DID-format string field, exercising the collision path.", 171 + ), 172 + ), 173 + required: Some( 174 + vec![ 175 + SmolStr::new_static("owner"), 176 + SmolStr::new_static("identifier") 177 + ], 178 + ), 179 + properties: { 180 + #[allow(unused_mut)] 181 + let mut map = BTreeMap::new(); 182 + map.insert( 183 + SmolStr::new_static("identifier"), 184 + LexObjectProperty::Ref(LexRef { 185 + r#ref: CowStr::new_static("#did"), 186 + ..Default::default() 187 + }), 188 + ); 189 + map.insert( 190 + SmolStr::new_static("label"), 191 + LexObjectProperty::String(LexString { 192 + max_length: Some(200usize), 193 + ..Default::default() 194 + }), 195 + ); 196 + map.insert( 197 + SmolStr::new_static("owner"), 198 + LexObjectProperty::String(LexString { 199 + description: Some( 200 + CowStr::new_static( 201 + "A field typed as DID format, requiring the Did import but colliding with local Did type.", 202 + ), 203 + ), 204 + format: Some(LexStringFormat::Did), 205 + ..Default::default() 206 + }), 207 + ); 208 + map 209 + }, 210 + ..Default::default() 211 + }), 212 + ); 213 + map 214 + }, 215 + ..Default::default() 216 + } 217 + } 218 + 219 + pub mod did_record_state { 220 + 221 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 222 + #[allow(unused)] 223 + use ::core::marker::PhantomData; 224 + mod sealed { 225 + pub trait Sealed {} 226 + } 227 + /// State trait tracking which required fields have been set 228 + pub trait State: sealed::Sealed { 229 + type Owner; 230 + type Identifier; 231 + } 232 + /// Empty state - all required fields are unset 233 + pub struct Empty(()); 234 + impl sealed::Sealed for Empty {} 235 + impl State for Empty { 236 + type Owner = Unset; 237 + type Identifier = Unset; 238 + } 239 + ///State transition - sets the `owner` field to Set 240 + pub struct SetOwner<St: State = Empty>(PhantomData<fn() -> St>); 241 + impl<St: State> sealed::Sealed for SetOwner<St> {} 242 + impl<St: State> State for SetOwner<St> { 243 + type Owner = Set<members::owner>; 244 + type Identifier = St::Identifier; 245 + } 246 + ///State transition - sets the `identifier` field to Set 247 + pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>); 248 + impl<St: State> sealed::Sealed for SetIdentifier<St> {} 249 + impl<St: State> State for SetIdentifier<St> { 250 + type Owner = St::Owner; 251 + type Identifier = Set<members::identifier>; 252 + } 253 + /// Marker types for field names 254 + #[allow(non_camel_case_types)] 255 + pub mod members { 256 + ///Marker type for the `owner` field 257 + pub struct owner(()); 258 + ///Marker type for the `identifier` field 259 + pub struct identifier(()); 260 + } 261 + } 262 + 263 + /// Builder for constructing an instance of this type. 264 + pub struct DidRecordBuilder<S: BosStr, St: did_record_state::State> { 265 + _state: PhantomData<fn() -> St>, 266 + _fields: ( 267 + Option<did::Did<S>>, 268 + Option<S>, 269 + Option<jacquard_common::types::string::Did<S>>, 270 + ), 271 + _type: PhantomData<fn() -> S>, 272 + } 273 + 274 + impl<S: BosStr> DidRecord<S> { 275 + /// Create a new builder for this type. 276 + pub fn new() -> DidRecordBuilder<S, did_record_state::Empty> { 277 + DidRecordBuilder::new() 278 + } 279 + } 280 + 281 + impl<S: BosStr> DidRecordBuilder<S, did_record_state::Empty> { 282 + /// Create a new builder with all fields unset. 283 + pub fn new() -> Self { 284 + DidRecordBuilder { 285 + _state: PhantomData, 286 + _fields: (None, None, None), 287 + _type: PhantomData, 288 + } 289 + } 290 + } 291 + 292 + impl<S: BosStr, St> DidRecordBuilder<S, St> 293 + where 294 + St: did_record_state::State, 295 + St::Identifier: did_record_state::IsUnset, 296 + { 297 + /// Set the `identifier` field (required) 298 + pub fn identifier( 299 + mut self, 300 + value: impl Into<did::Did<S>>, 301 + ) -> DidRecordBuilder<S, did_record_state::SetIdentifier<St>> { 302 + self._fields.0 = Option::Some(value.into()); 303 + DidRecordBuilder { 304 + _state: PhantomData, 305 + _fields: self._fields, 306 + _type: PhantomData, 307 + } 308 + } 309 + } 310 + 311 + impl<S: BosStr, St: did_record_state::State> DidRecordBuilder<S, St> { 312 + /// Set the `label` field (optional) 313 + pub fn label(mut self, value: impl Into<Option<S>>) -> Self { 314 + self._fields.1 = value.into(); 315 + self 316 + } 317 + /// Set the `label` field to an Option value (optional) 318 + pub fn maybe_label(mut self, value: Option<S>) -> Self { 319 + self._fields.1 = value; 320 + self 321 + } 322 + } 323 + 324 + impl<S: BosStr, St> DidRecordBuilder<S, St> 325 + where 326 + St: did_record_state::State, 327 + St::Owner: did_record_state::IsUnset, 328 + { 329 + /// Set the `owner` field (required) 330 + pub fn owner( 331 + mut self, 332 + value: impl Into<jacquard_common::types::string::Did<S>>, 333 + ) -> DidRecordBuilder<S, did_record_state::SetOwner<St>> { 334 + self._fields.2 = Option::Some(value.into()); 335 + DidRecordBuilder { 336 + _state: PhantomData, 337 + _fields: self._fields, 338 + _type: PhantomData, 339 + } 340 + } 341 + } 342 + 343 + impl<S: BosStr, St> DidRecordBuilder<S, St> 344 + where 345 + St: did_record_state::State, 346 + St::Owner: did_record_state::IsSet, 347 + St::Identifier: did_record_state::IsSet, 348 + { 349 + /// Build the final struct. 350 + pub fn build(self) -> DidRecord<S> { 351 + DidRecord { 352 + identifier: self._fields.0.unwrap(), 353 + label: self._fields.1, 354 + owner: self._fields.2.unwrap(), 355 + extra_data: Default::default(), 356 + } 357 + } 358 + /// Build the final struct with custom extra_data. 359 + pub fn build_with_data( 360 + self, 361 + extra_data: BTreeMap<SmolStr, Data<S>>, 362 + ) -> DidRecord<S> { 363 + DidRecord { 364 + identifier: self._fields.0.unwrap(), 365 + label: self._fields.1, 366 + owner: self._fields.2.unwrap(), 367 + extra_data: Some(extra_data), 368 + } 369 + } 370 + }
+305
crates/jacquard-codegen-tests/src/generated/pretty/test_collision/option.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.collision.option 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::value::Data; 19 + use jacquard_derive::IntoStatic; 20 + use jacquard_lexicon::lexicon::LexiconDoc; 21 + use jacquard_lexicon::schema::LexiconSchema; 22 + 23 + #[allow(unused_imports)] 24 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 25 + use serde::{Serialize, Deserialize}; 26 + use crate::pretty::test_collision::option; 27 + /// An object with optional fields, exercising the Option::is_none path collision. 28 + 29 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 30 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 31 + pub struct OptionRecord<S: BosStr = DefaultStr> { 32 + pub choice: option::OptionRecordOption<S>, 33 + #[serde(skip_serializing_if = "Option::is_none")] 34 + pub description: Option<S>, 35 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 36 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 37 + } 38 + 39 + /// A locally-defined type named Option, colliding with std::option::Option. 40 + 41 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 42 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 43 + pub struct OptionRecordOption<S: BosStr = DefaultStr> { 44 + pub key: S, 45 + pub value: S, 46 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 47 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 48 + } 49 + 50 + impl<S: BosStr> LexiconSchema for OptionRecord<S> { 51 + fn nsid() -> &'static str { 52 + "test.collision.option" 53 + } 54 + fn def_name() -> &'static str { 55 + "main" 56 + } 57 + fn lexicon_doc() -> LexiconDoc<'static> { 58 + lexicon_doc_test_collision_option() 59 + } 60 + fn validate(&self) -> Result<(), ConstraintError> { 61 + if let Some(ref value) = self.description { 62 + #[allow(unused_comparisons)] 63 + if <str>::len(value.as_ref()) > 500usize { 64 + return Err(ConstraintError::MaxLength { 65 + path: ValidationPath::from_field("description"), 66 + max: 500usize, 67 + actual: <str>::len(value.as_ref()), 68 + }); 69 + } 70 + } 71 + Ok(()) 72 + } 73 + } 74 + 75 + impl<S: BosStr> LexiconSchema for OptionRecordOption<S> { 76 + fn nsid() -> &'static str { 77 + "test.collision.option" 78 + } 79 + fn def_name() -> &'static str { 80 + "option" 81 + } 82 + fn lexicon_doc() -> LexiconDoc<'static> { 83 + lexicon_doc_test_collision_option() 84 + } 85 + fn validate(&self) -> Result<(), ConstraintError> { 86 + { 87 + let value = &self.key; 88 + #[allow(unused_comparisons)] 89 + if <str>::len(value.as_ref()) > 100usize { 90 + return Err(ConstraintError::MaxLength { 91 + path: ValidationPath::from_field("key"), 92 + max: 100usize, 93 + actual: <str>::len(value.as_ref()), 94 + }); 95 + } 96 + } 97 + { 98 + let value = &self.value; 99 + #[allow(unused_comparisons)] 100 + if <str>::len(value.as_ref()) > 500usize { 101 + return Err(ConstraintError::MaxLength { 102 + path: ValidationPath::from_field("value"), 103 + max: 500usize, 104 + actual: <str>::len(value.as_ref()), 105 + }); 106 + } 107 + } 108 + Ok(()) 109 + } 110 + } 111 + 112 + pub mod option_record_state { 113 + 114 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 115 + #[allow(unused)] 116 + use ::core::marker::PhantomData; 117 + mod sealed { 118 + pub trait Sealed {} 119 + } 120 + /// State trait tracking which required fields have been set 121 + pub trait State: sealed::Sealed { 122 + type Choice; 123 + } 124 + /// Empty state - all required fields are unset 125 + pub struct Empty(()); 126 + impl sealed::Sealed for Empty {} 127 + impl State for Empty { 128 + type Choice = Unset; 129 + } 130 + ///State transition - sets the `choice` field to Set 131 + pub struct SetChoice<St: State = Empty>(PhantomData<fn() -> St>); 132 + impl<St: State> sealed::Sealed for SetChoice<St> {} 133 + impl<St: State> State for SetChoice<St> { 134 + type Choice = Set<members::choice>; 135 + } 136 + /// Marker types for field names 137 + #[allow(non_camel_case_types)] 138 + pub mod members { 139 + ///Marker type for the `choice` field 140 + pub struct choice(()); 141 + } 142 + } 143 + 144 + /// Builder for constructing an instance of this type. 145 + pub struct OptionRecordBuilder<S: BosStr, St: option_record_state::State> { 146 + _state: PhantomData<fn() -> St>, 147 + _fields: (Option<option::OptionRecordOption<S>>, Option<S>), 148 + _type: PhantomData<fn() -> S>, 149 + } 150 + 151 + impl<S: BosStr> OptionRecord<S> { 152 + /// Create a new builder for this type. 153 + pub fn new() -> OptionRecordBuilder<S, option_record_state::Empty> { 154 + OptionRecordBuilder::new() 155 + } 156 + } 157 + 158 + impl<S: BosStr> OptionRecordBuilder<S, option_record_state::Empty> { 159 + /// Create a new builder with all fields unset. 160 + pub fn new() -> Self { 161 + OptionRecordBuilder { 162 + _state: PhantomData, 163 + _fields: (None, None), 164 + _type: PhantomData, 165 + } 166 + } 167 + } 168 + 169 + impl<S: BosStr, St> OptionRecordBuilder<S, St> 170 + where 171 + St: option_record_state::State, 172 + St::Choice: option_record_state::IsUnset, 173 + { 174 + /// Set the `choice` field (required) 175 + pub fn choice( 176 + mut self, 177 + value: impl Into<option::OptionRecordOption<S>>, 178 + ) -> OptionRecordBuilder<S, option_record_state::SetChoice<St>> { 179 + self._fields.0 = Option::Some(value.into()); 180 + OptionRecordBuilder { 181 + _state: PhantomData, 182 + _fields: self._fields, 183 + _type: PhantomData, 184 + } 185 + } 186 + } 187 + 188 + impl<S: BosStr, St: option_record_state::State> OptionRecordBuilder<S, St> { 189 + /// Set the `description` field (optional) 190 + pub fn description(mut self, value: impl Into<Option<S>>) -> Self { 191 + self._fields.1 = value.into(); 192 + self 193 + } 194 + /// Set the `description` field to an Option value (optional) 195 + pub fn maybe_description(mut self, value: Option<S>) -> Self { 196 + self._fields.1 = value; 197 + self 198 + } 199 + } 200 + 201 + impl<S: BosStr, St> OptionRecordBuilder<S, St> 202 + where 203 + St: option_record_state::State, 204 + St::Choice: option_record_state::IsSet, 205 + { 206 + /// Build the final struct. 207 + pub fn build(self) -> OptionRecord<S> { 208 + OptionRecord { 209 + choice: self._fields.0.unwrap(), 210 + description: self._fields.1, 211 + extra_data: Default::default(), 212 + } 213 + } 214 + /// Build the final struct with custom extra_data. 215 + pub fn build_with_data( 216 + self, 217 + extra_data: BTreeMap<SmolStr, Data<S>>, 218 + ) -> OptionRecord<S> { 219 + OptionRecord { 220 + choice: self._fields.0.unwrap(), 221 + description: self._fields.1, 222 + extra_data: Some(extra_data), 223 + } 224 + } 225 + } 226 + 227 + fn lexicon_doc_test_collision_option() -> LexiconDoc<'static> { 228 + #[allow(unused_imports)] 229 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 230 + use jacquard_lexicon::lexicon::*; 231 + use alloc::collections::BTreeMap; 232 + LexiconDoc { 233 + lexicon: Lexicon::Lexicon1, 234 + id: CowStr::new_static("test.collision.option"), 235 + defs: { 236 + let mut map = BTreeMap::new(); 237 + map.insert( 238 + SmolStr::new_static("main"), 239 + LexUserType::Object(LexObject { 240 + description: Some( 241 + CowStr::new_static( 242 + "An object with optional fields, exercising the Option::is_none path collision.", 243 + ), 244 + ), 245 + required: Some(vec![SmolStr::new_static("choice")]), 246 + properties: { 247 + #[allow(unused_mut)] 248 + let mut map = BTreeMap::new(); 249 + map.insert( 250 + SmolStr::new_static("choice"), 251 + LexObjectProperty::Ref(LexRef { 252 + r#ref: CowStr::new_static("#option"), 253 + ..Default::default() 254 + }), 255 + ); 256 + map.insert( 257 + SmolStr::new_static("description"), 258 + LexObjectProperty::String(LexString { 259 + max_length: Some(500usize), 260 + ..Default::default() 261 + }), 262 + ); 263 + map 264 + }, 265 + ..Default::default() 266 + }), 267 + ); 268 + map.insert( 269 + SmolStr::new_static("option"), 270 + LexUserType::Object(LexObject { 271 + description: Some( 272 + CowStr::new_static( 273 + "A locally-defined type named Option, colliding with std::option::Option.", 274 + ), 275 + ), 276 + required: Some( 277 + vec![SmolStr::new_static("key"), SmolStr::new_static("value")], 278 + ), 279 + properties: { 280 + #[allow(unused_mut)] 281 + let mut map = BTreeMap::new(); 282 + map.insert( 283 + SmolStr::new_static("key"), 284 + LexObjectProperty::String(LexString { 285 + max_length: Some(100usize), 286 + ..Default::default() 287 + }), 288 + ); 289 + map.insert( 290 + SmolStr::new_static("value"), 291 + LexObjectProperty::String(LexString { 292 + max_length: Some(500usize), 293 + ..Default::default() 294 + }), 295 + ); 296 + map 297 + }, 298 + ..Default::default() 299 + }), 300 + ); 301 + map 302 + }, 303 + ..Default::default() 304 + } 305 + }
+165
crates/jacquard-codegen-tests/src/generated/pretty/test_ns1.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.ns1.defs 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 11 + 12 + #[allow(unused_imports)] 13 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 14 + use jacquard_common::deps::smol_str::SmolStr; 15 + use jacquard_common::types::value::Data; 16 + use jacquard_derive::IntoStatic; 17 + use jacquard_lexicon::lexicon::LexiconDoc; 18 + use jacquard_lexicon::schema::LexiconSchema; 19 + 20 + #[allow(unused_imports)] 21 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 22 + use serde::{Serialize, Deserialize}; 23 + /// Another type in ns1 for cross-namespace ref testing. 24 + 25 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 26 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 27 + pub struct Bar<S: BosStr = DefaultStr> { 28 + pub tag: S, 29 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 30 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 31 + } 32 + 33 + /// A type defined in ns1, referenced cross-namespace by ns2. 34 + 35 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] 36 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 37 + pub struct Foo<S: BosStr = DefaultStr> { 38 + pub name: S, 39 + #[serde(skip_serializing_if = "Option::is_none")] 40 + pub value: Option<i64>, 41 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 42 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 43 + } 44 + 45 + impl<S: BosStr> LexiconSchema for Bar<S> { 46 + fn nsid() -> &'static str { 47 + "test.ns1.defs" 48 + } 49 + fn def_name() -> &'static str { 50 + "bar" 51 + } 52 + fn lexicon_doc() -> LexiconDoc<'static> { 53 + lexicon_doc_test_ns1_defs() 54 + } 55 + fn validate(&self) -> Result<(), ConstraintError> { 56 + { 57 + let value = &self.tag; 58 + #[allow(unused_comparisons)] 59 + if <str>::len(value.as_ref()) > 50usize { 60 + return Err(ConstraintError::MaxLength { 61 + path: ValidationPath::from_field("tag"), 62 + max: 50usize, 63 + actual: <str>::len(value.as_ref()), 64 + }); 65 + } 66 + } 67 + Ok(()) 68 + } 69 + } 70 + 71 + impl<S: BosStr> LexiconSchema for Foo<S> { 72 + fn nsid() -> &'static str { 73 + "test.ns1.defs" 74 + } 75 + fn def_name() -> &'static str { 76 + "foo" 77 + } 78 + fn lexicon_doc() -> LexiconDoc<'static> { 79 + lexicon_doc_test_ns1_defs() 80 + } 81 + fn validate(&self) -> Result<(), ConstraintError> { 82 + { 83 + let value = &self.name; 84 + #[allow(unused_comparisons)] 85 + if <str>::len(value.as_ref()) > 100usize { 86 + return Err(ConstraintError::MaxLength { 87 + path: ValidationPath::from_field("name"), 88 + max: 100usize, 89 + actual: <str>::len(value.as_ref()), 90 + }); 91 + } 92 + } 93 + Ok(()) 94 + } 95 + } 96 + 97 + fn lexicon_doc_test_ns1_defs() -> LexiconDoc<'static> { 98 + #[allow(unused_imports)] 99 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 100 + use jacquard_lexicon::lexicon::*; 101 + use alloc::collections::BTreeMap; 102 + LexiconDoc { 103 + lexicon: Lexicon::Lexicon1, 104 + id: CowStr::new_static("test.ns1.defs"), 105 + defs: { 106 + let mut map = BTreeMap::new(); 107 + map.insert( 108 + SmolStr::new_static("bar"), 109 + LexUserType::Object(LexObject { 110 + description: Some( 111 + CowStr::new_static( 112 + "Another type in ns1 for cross-namespace ref testing.", 113 + ), 114 + ), 115 + required: Some(vec![SmolStr::new_static("tag")]), 116 + properties: { 117 + #[allow(unused_mut)] 118 + let mut map = BTreeMap::new(); 119 + map.insert( 120 + SmolStr::new_static("tag"), 121 + LexObjectProperty::String(LexString { 122 + max_length: Some(50usize), 123 + ..Default::default() 124 + }), 125 + ); 126 + map 127 + }, 128 + ..Default::default() 129 + }), 130 + ); 131 + map.insert( 132 + SmolStr::new_static("foo"), 133 + LexUserType::Object(LexObject { 134 + description: Some( 135 + CowStr::new_static( 136 + "A type defined in ns1, referenced cross-namespace by ns2.", 137 + ), 138 + ), 139 + required: Some(vec![SmolStr::new_static("name")]), 140 + properties: { 141 + #[allow(unused_mut)] 142 + let mut map = BTreeMap::new(); 143 + map.insert( 144 + SmolStr::new_static("name"), 145 + LexObjectProperty::String(LexString { 146 + max_length: Some(100usize), 147 + ..Default::default() 148 + }), 149 + ); 150 + map.insert( 151 + SmolStr::new_static("value"), 152 + LexObjectProperty::Integer(LexInteger { 153 + ..Default::default() 154 + }), 155 + ); 156 + map 157 + }, 158 + ..Default::default() 159 + }), 160 + ); 161 + map 162 + }, 163 + ..Default::default() 164 + } 165 + }
+6
crates/jacquard-codegen-tests/src/generated/pretty/test_ns2.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod consumer;
+249
crates/jacquard-codegen-tests/src/generated/pretty/test_ns2/consumer.rs
··· 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 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::value::Data; 19 + use jacquard_derive::IntoStatic; 20 + use jacquard_lexicon::lexicon::LexiconDoc; 21 + use jacquard_lexicon::schema::LexiconSchema; 22 + 23 + #[allow(unused_imports)] 24 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 25 + use serde::{Serialize, Deserialize}; 26 + use crate::pretty::test_ns1::Bar; 27 + use crate::pretty::test_ns1::Foo; 28 + /// An object that references types across namespaces. 29 + 30 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 31 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 32 + pub struct Consumer<S: BosStr = DefaultStr> { 33 + #[serde(skip_serializing_if = "Option::is_none")] 34 + pub description: Option<S>, 35 + pub item: Foo<S>, 36 + #[serde(skip_serializing_if = "Option::is_none")] 37 + pub tags: Option<Vec<Bar<S>>>, 38 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 39 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 40 + } 41 + 42 + impl<S: BosStr> LexiconSchema for Consumer<S> { 43 + fn nsid() -> &'static str { 44 + "test.ns2.consumer" 45 + } 46 + fn def_name() -> &'static str { 47 + "main" 48 + } 49 + fn lexicon_doc() -> LexiconDoc<'static> { 50 + lexicon_doc_test_ns2_consumer() 51 + } 52 + fn validate(&self) -> Result<(), ConstraintError> { 53 + if let Some(ref value) = self.description { 54 + #[allow(unused_comparisons)] 55 + if <str>::len(value.as_ref()) > 500usize { 56 + return Err(ConstraintError::MaxLength { 57 + path: ValidationPath::from_field("description"), 58 + max: 500usize, 59 + actual: <str>::len(value.as_ref()), 60 + }); 61 + } 62 + } 63 + Ok(()) 64 + } 65 + } 66 + 67 + pub 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. 100 + pub struct ConsumerBuilder<S: BosStr, St: consumer_state::State> { 101 + _state: PhantomData<fn() -> St>, 102 + _fields: (Option<S>, Option<Foo<S>>, Option<Vec<Bar<S>>>), 103 + _type: PhantomData<fn() -> S>, 104 + } 105 + 106 + impl<S: BosStr> Consumer<S> { 107 + /// Create a new builder for this type. 108 + pub fn new() -> ConsumerBuilder<S, consumer_state::Empty> { 109 + ConsumerBuilder::new() 110 + } 111 + } 112 + 113 + impl<S: BosStr> ConsumerBuilder<S, consumer_state::Empty> { 114 + /// Create a new builder with all fields unset. 115 + pub fn new() -> Self { 116 + ConsumerBuilder { 117 + _state: PhantomData, 118 + _fields: (None, None, None), 119 + _type: PhantomData, 120 + } 121 + } 122 + } 123 + 124 + impl<S: BosStr, St: consumer_state::State> ConsumerBuilder<S, St> { 125 + /// Set the `description` field (optional) 126 + pub fn description(mut self, value: impl Into<Option<S>>) -> Self { 127 + self._fields.0 = value.into(); 128 + self 129 + } 130 + /// Set the `description` field to an Option value (optional) 131 + pub fn maybe_description(mut self, value: Option<S>) -> Self { 132 + self._fields.0 = value; 133 + self 134 + } 135 + } 136 + 137 + impl<S: BosStr, St> ConsumerBuilder<S, St> 138 + where 139 + St: consumer_state::State, 140 + St::Item: consumer_state::IsUnset, 141 + { 142 + /// Set the `item` field (required) 143 + pub fn item( 144 + mut self, 145 + value: impl Into<Foo<S>>, 146 + ) -> ConsumerBuilder<S, consumer_state::SetItem<St>> { 147 + self._fields.1 = Option::Some(value.into()); 148 + ConsumerBuilder { 149 + _state: PhantomData, 150 + _fields: self._fields, 151 + _type: PhantomData, 152 + } 153 + } 154 + } 155 + 156 + impl<S: BosStr, St: consumer_state::State> ConsumerBuilder<S, St> { 157 + /// Set the `tags` field (optional) 158 + pub fn tags(mut self, value: impl Into<Option<Vec<Bar<S>>>>) -> Self { 159 + self._fields.2 = value.into(); 160 + self 161 + } 162 + /// Set the `tags` field to an Option value (optional) 163 + pub fn maybe_tags(mut self, value: Option<Vec<Bar<S>>>) -> Self { 164 + self._fields.2 = value; 165 + self 166 + } 167 + } 168 + 169 + impl<S: BosStr, St> ConsumerBuilder<S, St> 170 + where 171 + St: consumer_state::State, 172 + St::Item: consumer_state::IsSet, 173 + { 174 + /// Build the final struct. 175 + pub fn build(self) -> Consumer<S> { 176 + Consumer { 177 + description: self._fields.0, 178 + item: self._fields.1.unwrap(), 179 + tags: self._fields.2, 180 + extra_data: Default::default(), 181 + } 182 + } 183 + /// Build the final struct with custom extra_data. 184 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Consumer<S> { 185 + Consumer { 186 + description: self._fields.0, 187 + item: self._fields.1.unwrap(), 188 + tags: self._fields.2, 189 + extra_data: Some(extra_data), 190 + } 191 + } 192 + } 193 + 194 + fn lexicon_doc_test_ns2_consumer() -> LexiconDoc<'static> { 195 + #[allow(unused_imports)] 196 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 197 + use jacquard_lexicon::lexicon::*; 198 + use alloc::collections::BTreeMap; 199 + LexiconDoc { 200 + lexicon: Lexicon::Lexicon1, 201 + id: CowStr::new_static("test.ns2.consumer"), 202 + defs: { 203 + let mut map = BTreeMap::new(); 204 + map.insert( 205 + SmolStr::new_static("main"), 206 + LexUserType::Object(LexObject { 207 + description: Some( 208 + CowStr::new_static( 209 + "An object that references types across namespaces.", 210 + ), 211 + ), 212 + required: Some(vec![SmolStr::new_static("item")]), 213 + properties: { 214 + #[allow(unused_mut)] 215 + let mut map = BTreeMap::new(); 216 + map.insert( 217 + SmolStr::new_static("description"), 218 + LexObjectProperty::String(LexString { 219 + max_length: Some(500usize), 220 + ..Default::default() 221 + }), 222 + ); 223 + map.insert( 224 + SmolStr::new_static("item"), 225 + LexObjectProperty::Ref(LexRef { 226 + r#ref: CowStr::new_static("test.ns1.defs#foo"), 227 + ..Default::default() 228 + }), 229 + ); 230 + map.insert( 231 + SmolStr::new_static("tags"), 232 + LexObjectProperty::Array(LexArray { 233 + items: LexArrayItem::Ref(LexRef { 234 + r#ref: CowStr::new_static("test.ns1.defs#bar"), 235 + ..Default::default() 236 + }), 237 + ..Default::default() 238 + }), 239 + ); 240 + map 241 + }, 242 + ..Default::default() 243 + }), 244 + ); 245 + map 246 + }, 247 + ..Default::default() 248 + } 249 + }
+6
crates/jacquard-codegen-tests/src/generated/pretty/test_ns3.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // This file was automatically generated from Lexicon schemas. 4 + // Any manual changes will be overwritten on the next regeneration. 5 + 6 + pub mod collision;
+438
crates/jacquard-codegen-tests/src/generated/pretty/test_ns3/collision.rs
··· 1 + // @generated by jacquard-lexicon. DO NOT EDIT. 2 + // 3 + // Lexicon: test.ns3.collision 4 + // 5 + // This file was automatically generated from Lexicon schemas. 6 + // Any manual changes will be overwritten on the next regeneration. 7 + 8 + #[allow(unused_imports)] 9 + use alloc::collections::BTreeMap; 10 + 11 + #[allow(unused_imports)] 12 + use core::marker::PhantomData; 13 + use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr}; 14 + 15 + #[allow(unused_imports)] 16 + use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; 17 + use jacquard_common::deps::smol_str::SmolStr; 18 + use jacquard_common::types::value::Data; 19 + use jacquard_derive::IntoStatic; 20 + use jacquard_lexicon::lexicon::LexiconDoc; 21 + use jacquard_lexicon::schema::LexiconSchema; 22 + 23 + #[allow(unused_imports)] 24 + use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; 25 + use serde::{Serialize, Deserialize}; 26 + use crate::pretty::test_ns1; 27 + use crate::pretty::test_ns3::collision; 28 + /// A locally-defined Foo that shares a name with test.ns1.defs#foo. 29 + 30 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 31 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 32 + pub struct Foo<S: BosStr = DefaultStr> { 33 + #[serde(skip_serializing_if = "Option::is_none")] 34 + pub label: Option<S>, 35 + pub local_id: i64, 36 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 37 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 38 + } 39 + 40 + /// An object with both a local Foo ref and a cross-namespace Foo ref. 41 + 42 + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] 43 + #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] 44 + pub struct Collision<S: BosStr = DefaultStr> { 45 + pub external_foo: test_ns1::Foo<S>, 46 + pub local_foo: collision::Foo<S>, 47 + #[serde(skip_serializing_if = "Option::is_none")] 48 + pub note: Option<S>, 49 + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] 50 + pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>, 51 + } 52 + 53 + impl<S: BosStr> LexiconSchema for Foo<S> { 54 + fn nsid() -> &'static str { 55 + "test.ns3.collision" 56 + } 57 + fn def_name() -> &'static str { 58 + "foo" 59 + } 60 + fn lexicon_doc() -> LexiconDoc<'static> { 61 + lexicon_doc_test_ns3_collision() 62 + } 63 + fn validate(&self) -> Result<(), ConstraintError> { 64 + if let Some(ref value) = self.label { 65 + #[allow(unused_comparisons)] 66 + if <str>::len(value.as_ref()) > 100usize { 67 + return Err(ConstraintError::MaxLength { 68 + path: ValidationPath::from_field("label"), 69 + max: 100usize, 70 + actual: <str>::len(value.as_ref()), 71 + }); 72 + } 73 + } 74 + Ok(()) 75 + } 76 + } 77 + 78 + impl<S: BosStr> LexiconSchema for Collision<S> { 79 + fn nsid() -> &'static str { 80 + "test.ns3.collision" 81 + } 82 + fn def_name() -> &'static str { 83 + "main" 84 + } 85 + fn lexicon_doc() -> LexiconDoc<'static> { 86 + lexicon_doc_test_ns3_collision() 87 + } 88 + fn validate(&self) -> Result<(), ConstraintError> { 89 + Ok(()) 90 + } 91 + } 92 + 93 + pub mod foo_state { 94 + 95 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 96 + #[allow(unused)] 97 + use ::core::marker::PhantomData; 98 + mod sealed { 99 + pub trait Sealed {} 100 + } 101 + /// State trait tracking which required fields have been set 102 + pub trait State: sealed::Sealed { 103 + type LocalId; 104 + } 105 + /// Empty state - all required fields are unset 106 + pub struct Empty(()); 107 + impl sealed::Sealed for Empty {} 108 + impl State for Empty { 109 + type LocalId = Unset; 110 + } 111 + ///State transition - sets the `local_id` field to Set 112 + pub struct SetLocalId<St: State = Empty>(PhantomData<fn() -> St>); 113 + impl<St: State> sealed::Sealed for SetLocalId<St> {} 114 + impl<St: State> State for SetLocalId<St> { 115 + type LocalId = Set<members::local_id>; 116 + } 117 + /// Marker types for field names 118 + #[allow(non_camel_case_types)] 119 + pub mod members { 120 + ///Marker type for the `local_id` field 121 + pub struct local_id(()); 122 + } 123 + } 124 + 125 + /// Builder for constructing an instance of this type. 126 + pub struct FooBuilder<S: BosStr, St: foo_state::State> { 127 + _state: PhantomData<fn() -> St>, 128 + _fields: (Option<S>, Option<i64>), 129 + _type: PhantomData<fn() -> S>, 130 + } 131 + 132 + impl<S: BosStr> Foo<S> { 133 + /// Create a new builder for this type. 134 + pub fn new() -> FooBuilder<S, foo_state::Empty> { 135 + FooBuilder::new() 136 + } 137 + } 138 + 139 + impl<S: BosStr> FooBuilder<S, foo_state::Empty> { 140 + /// Create a new builder with all fields unset. 141 + pub fn new() -> Self { 142 + FooBuilder { 143 + _state: PhantomData, 144 + _fields: (None, None), 145 + _type: PhantomData, 146 + } 147 + } 148 + } 149 + 150 + impl<S: BosStr, St: foo_state::State> FooBuilder<S, St> { 151 + /// Set the `label` field (optional) 152 + pub fn label(mut self, value: impl Into<Option<S>>) -> Self { 153 + self._fields.0 = value.into(); 154 + self 155 + } 156 + /// Set the `label` field to an Option value (optional) 157 + pub fn maybe_label(mut self, value: Option<S>) -> Self { 158 + self._fields.0 = value; 159 + self 160 + } 161 + } 162 + 163 + impl<S: BosStr, St> FooBuilder<S, St> 164 + where 165 + St: foo_state::State, 166 + St::LocalId: foo_state::IsUnset, 167 + { 168 + /// Set the `localId` field (required) 169 + pub fn local_id( 170 + mut self, 171 + value: impl Into<i64>, 172 + ) -> FooBuilder<S, foo_state::SetLocalId<St>> { 173 + self._fields.1 = Option::Some(value.into()); 174 + FooBuilder { 175 + _state: PhantomData, 176 + _fields: self._fields, 177 + _type: PhantomData, 178 + } 179 + } 180 + } 181 + 182 + impl<S: BosStr, St> FooBuilder<S, St> 183 + where 184 + St: foo_state::State, 185 + St::LocalId: foo_state::IsSet, 186 + { 187 + /// Build the final struct. 188 + pub fn build(self) -> Foo<S> { 189 + Foo { 190 + label: self._fields.0, 191 + local_id: self._fields.1.unwrap(), 192 + extra_data: Default::default(), 193 + } 194 + } 195 + /// Build the final struct with custom extra_data. 196 + pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Foo<S> { 197 + Foo { 198 + label: self._fields.0, 199 + local_id: self._fields.1.unwrap(), 200 + extra_data: Some(extra_data), 201 + } 202 + } 203 + } 204 + 205 + fn lexicon_doc_test_ns3_collision() -> LexiconDoc<'static> { 206 + #[allow(unused_imports)] 207 + use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; 208 + use jacquard_lexicon::lexicon::*; 209 + use alloc::collections::BTreeMap; 210 + LexiconDoc { 211 + lexicon: Lexicon::Lexicon1, 212 + id: CowStr::new_static("test.ns3.collision"), 213 + defs: { 214 + let mut map = BTreeMap::new(); 215 + map.insert( 216 + SmolStr::new_static("foo"), 217 + LexUserType::Object(LexObject { 218 + description: Some( 219 + CowStr::new_static( 220 + "A locally-defined Foo that shares a name with test.ns1.defs#foo.", 221 + ), 222 + ), 223 + required: Some(vec![SmolStr::new_static("localId")]), 224 + properties: { 225 + #[allow(unused_mut)] 226 + let mut map = BTreeMap::new(); 227 + map.insert( 228 + SmolStr::new_static("label"), 229 + LexObjectProperty::String(LexString { 230 + max_length: Some(100usize), 231 + ..Default::default() 232 + }), 233 + ); 234 + map.insert( 235 + SmolStr::new_static("localId"), 236 + LexObjectProperty::Integer(LexInteger { 237 + ..Default::default() 238 + }), 239 + ); 240 + map 241 + }, 242 + ..Default::default() 243 + }), 244 + ); 245 + map.insert( 246 + SmolStr::new_static("main"), 247 + LexUserType::Object(LexObject { 248 + description: Some( 249 + CowStr::new_static( 250 + "An object with both a local Foo ref and a cross-namespace Foo ref.", 251 + ), 252 + ), 253 + required: Some( 254 + vec![ 255 + SmolStr::new_static("localFoo"), 256 + SmolStr::new_static("externalFoo") 257 + ], 258 + ), 259 + properties: { 260 + #[allow(unused_mut)] 261 + let mut map = BTreeMap::new(); 262 + map.insert( 263 + SmolStr::new_static("externalFoo"), 264 + LexObjectProperty::Ref(LexRef { 265 + r#ref: CowStr::new_static("test.ns1.defs#foo"), 266 + ..Default::default() 267 + }), 268 + ); 269 + map.insert( 270 + SmolStr::new_static("localFoo"), 271 + LexObjectProperty::Ref(LexRef { 272 + r#ref: CowStr::new_static("#foo"), 273 + ..Default::default() 274 + }), 275 + ); 276 + map.insert( 277 + SmolStr::new_static("note"), 278 + LexObjectProperty::String(LexString { ..Default::default() }), 279 + ); 280 + map 281 + }, 282 + ..Default::default() 283 + }), 284 + ); 285 + map 286 + }, 287 + ..Default::default() 288 + } 289 + } 290 + 291 + pub mod collision_state { 292 + 293 + pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 294 + #[allow(unused)] 295 + use ::core::marker::PhantomData; 296 + mod sealed { 297 + pub trait Sealed {} 298 + } 299 + /// State trait tracking which required fields have been set 300 + pub trait State: sealed::Sealed { 301 + type ExternalFoo; 302 + type LocalFoo; 303 + } 304 + /// Empty state - all required fields are unset 305 + pub struct Empty(()); 306 + impl sealed::Sealed for Empty {} 307 + impl State for Empty { 308 + type ExternalFoo = Unset; 309 + type LocalFoo = Unset; 310 + } 311 + ///State transition - sets the `external_foo` field to Set 312 + pub struct SetExternalFoo<St: State = Empty>(PhantomData<fn() -> St>); 313 + impl<St: State> sealed::Sealed for SetExternalFoo<St> {} 314 + impl<St: State> State for SetExternalFoo<St> { 315 + type ExternalFoo = Set<members::external_foo>; 316 + type LocalFoo = St::LocalFoo; 317 + } 318 + ///State transition - sets the `local_foo` field to Set 319 + pub struct SetLocalFoo<St: State = Empty>(PhantomData<fn() -> St>); 320 + impl<St: State> sealed::Sealed for SetLocalFoo<St> {} 321 + impl<St: State> State for SetLocalFoo<St> { 322 + type ExternalFoo = St::ExternalFoo; 323 + type LocalFoo = Set<members::local_foo>; 324 + } 325 + /// Marker types for field names 326 + #[allow(non_camel_case_types)] 327 + pub mod members { 328 + ///Marker type for the `external_foo` field 329 + pub struct external_foo(()); 330 + ///Marker type for the `local_foo` field 331 + pub struct local_foo(()); 332 + } 333 + } 334 + 335 + /// Builder for constructing an instance of this type. 336 + pub struct CollisionBuilder<S: BosStr, St: collision_state::State> { 337 + _state: PhantomData<fn() -> St>, 338 + _fields: (Option<test_ns1::Foo<S>>, Option<collision::Foo<S>>, Option<S>), 339 + _type: PhantomData<fn() -> S>, 340 + } 341 + 342 + impl<S: BosStr> Collision<S> { 343 + /// Create a new builder for this type. 344 + pub fn new() -> CollisionBuilder<S, collision_state::Empty> { 345 + CollisionBuilder::new() 346 + } 347 + } 348 + 349 + impl<S: BosStr> CollisionBuilder<S, collision_state::Empty> { 350 + /// Create a new builder with all fields unset. 351 + pub fn new() -> Self { 352 + CollisionBuilder { 353 + _state: PhantomData, 354 + _fields: (None, None, None), 355 + _type: PhantomData, 356 + } 357 + } 358 + } 359 + 360 + impl<S: BosStr, St> CollisionBuilder<S, St> 361 + where 362 + St: collision_state::State, 363 + St::ExternalFoo: collision_state::IsUnset, 364 + { 365 + /// Set the `externalFoo` field (required) 366 + pub fn external_foo( 367 + mut self, 368 + value: impl Into<test_ns1::Foo<S>>, 369 + ) -> CollisionBuilder<S, collision_state::SetExternalFoo<St>> { 370 + self._fields.0 = Option::Some(value.into()); 371 + CollisionBuilder { 372 + _state: PhantomData, 373 + _fields: self._fields, 374 + _type: PhantomData, 375 + } 376 + } 377 + } 378 + 379 + impl<S: BosStr, St> CollisionBuilder<S, St> 380 + where 381 + St: collision_state::State, 382 + St::LocalFoo: collision_state::IsUnset, 383 + { 384 + /// Set the `localFoo` field (required) 385 + pub fn local_foo( 386 + mut self, 387 + value: impl Into<collision::Foo<S>>, 388 + ) -> CollisionBuilder<S, collision_state::SetLocalFoo<St>> { 389 + self._fields.1 = Option::Some(value.into()); 390 + CollisionBuilder { 391 + _state: PhantomData, 392 + _fields: self._fields, 393 + _type: PhantomData, 394 + } 395 + } 396 + } 397 + 398 + impl<S: BosStr, St: collision_state::State> CollisionBuilder<S, St> { 399 + /// Set the `note` field (optional) 400 + pub fn note(mut self, value: impl Into<Option<S>>) -> Self { 401 + self._fields.2 = value.into(); 402 + self 403 + } 404 + /// Set the `note` field to an Option value (optional) 405 + pub fn maybe_note(mut self, value: Option<S>) -> Self { 406 + self._fields.2 = value; 407 + self 408 + } 409 + } 410 + 411 + impl<S: BosStr, St> CollisionBuilder<S, St> 412 + where 413 + St: collision_state::State, 414 + St::ExternalFoo: collision_state::IsSet, 415 + St::LocalFoo: collision_state::IsSet, 416 + { 417 + /// Build the final struct. 418 + pub fn build(self) -> Collision<S> { 419 + Collision { 420 + external_foo: self._fields.0.unwrap(), 421 + local_foo: self._fields.1.unwrap(), 422 + note: self._fields.2, 423 + extra_data: Default::default(), 424 + } 425 + } 426 + /// Build the final struct with custom extra_data. 427 + pub fn build_with_data( 428 + self, 429 + extra_data: BTreeMap<SmolStr, Data<S>>, 430 + ) -> Collision<S> { 431 + Collision { 432 + external_foo: self._fields.0.unwrap(), 433 + local_foo: self._fields.1.unwrap(), 434 + note: self._fields.2, 435 + extra_data: Some(extra_data), 436 + } 437 + } 438 + }
+144
crates/jacquard-codegen-tests/tests/fixtures/app_bsky_feed_post.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.feed.post", 4 + "defs": { 5 + "entity": { 6 + "type": "object", 7 + "description": "Deprecated: use facets instead.", 8 + "required": [ 9 + "index", 10 + "type", 11 + "value" 12 + ], 13 + "properties": { 14 + "index": { 15 + "type": "ref", 16 + "ref": "#textSlice" 17 + }, 18 + "type": { 19 + "type": "string", 20 + "description": "Expected values are 'mention' and 'link'." 21 + }, 22 + "value": { 23 + "type": "string" 24 + } 25 + } 26 + }, 27 + "main": { 28 + "type": "record", 29 + "description": "Record containing a Bluesky post.", 30 + "key": "tid", 31 + "record": { 32 + "type": "object", 33 + "required": [ 34 + "text", 35 + "createdAt" 36 + ], 37 + "properties": { 38 + "createdAt": { 39 + "type": "string", 40 + "description": "Client-declared timestamp when this post was originally created.", 41 + "format": "datetime" 42 + }, 43 + "embed": { 44 + "type": "union", 45 + "refs": [ 46 + "app.bsky.embed.images", 47 + "app.bsky.embed.video", 48 + "app.bsky.embed.external", 49 + "app.bsky.embed.record", 50 + "app.bsky.embed.recordWithMedia" 51 + ] 52 + }, 53 + "entities": { 54 + "type": "array", 55 + "description": "DEPRECATED: replaced by app.bsky.richtext.facet.", 56 + "items": { 57 + "type": "ref", 58 + "ref": "#entity" 59 + } 60 + }, 61 + "facets": { 62 + "type": "array", 63 + "description": "Annotations of text (mentions, URLs, hashtags, etc)", 64 + "items": { 65 + "type": "ref", 66 + "ref": "app.bsky.richtext.facet" 67 + } 68 + }, 69 + "labels": { 70 + "type": "union", 71 + "description": "Self-label values for this post. Effectively content warnings.", 72 + "refs": [ 73 + "com.atproto.label.defs#selfLabels" 74 + ] 75 + }, 76 + "langs": { 77 + "type": "array", 78 + "description": "Indicates human language of post primary text content.", 79 + "items": { 80 + "type": "string", 81 + "format": "language" 82 + }, 83 + "maxLength": 3 84 + }, 85 + "reply": { 86 + "type": "ref", 87 + "ref": "#replyRef" 88 + }, 89 + "tags": { 90 + "type": "array", 91 + "description": "Additional hashtags, in addition to any included in post text and facets.", 92 + "items": { 93 + "type": "string", 94 + "maxLength": 640, 95 + "maxGraphemes": 64 96 + }, 97 + "maxLength": 8 98 + }, 99 + "text": { 100 + "type": "string", 101 + "description": "The primary post content. May be an empty string, if there are embeds.", 102 + "maxLength": 3000, 103 + "maxGraphemes": 300 104 + } 105 + } 106 + } 107 + }, 108 + "replyRef": { 109 + "type": "object", 110 + "required": [ 111 + "root", 112 + "parent" 113 + ], 114 + "properties": { 115 + "parent": { 116 + "type": "ref", 117 + "ref": "com.atproto.repo.strongRef" 118 + }, 119 + "root": { 120 + "type": "ref", 121 + "ref": "com.atproto.repo.strongRef" 122 + } 123 + } 124 + }, 125 + "textSlice": { 126 + "type": "object", 127 + "description": "Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings.", 128 + "required": [ 129 + "start", 130 + "end" 131 + ], 132 + "properties": { 133 + "end": { 134 + "type": "integer", 135 + "minimum": 0 136 + }, 137 + "start": { 138 + "type": "integer", 139 + "minimum": 0 140 + } 141 + } 142 + } 143 + } 144 + }
+74
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/arrayTypes.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "test.array.types", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "properties": { 8 + "simpleStrings": { 9 + "type": "array", 10 + "items": { 11 + "type": "string" 12 + } 13 + }, 14 + "unionItems": { 15 + "type": "array", 16 + "items": { 17 + "type": "union", 18 + "refs": ["#textItem", "#imageItem"] 19 + } 20 + }, 21 + "refItems": { 22 + "type": "array", 23 + "items": { 24 + "type": "ref", 25 + "ref": "#nestedObject" 26 + } 27 + }, 28 + "objectItems": { 29 + "type": "array", 30 + "items": { 31 + "type": "object", 32 + "properties": { 33 + "inline": { 34 + "type": "string" 35 + } 36 + } 37 + } 38 + }, 39 + "cidLinks": { 40 + "type": "array", 41 + "items": { 42 + "type": "cid-link" 43 + } 44 + } 45 + } 46 + }, 47 + "textItem": { 48 + "type": "object", 49 + "required": ["text"], 50 + "properties": { 51 + "text": { 52 + "type": "string" 53 + } 54 + } 55 + }, 56 + "imageItem": { 57 + "type": "object", 58 + "required": ["blob"], 59 + "properties": { 60 + "blob": { 61 + "type": "blob" 62 + } 63 + } 64 + }, 65 + "nestedObject": { 66 + "type": "object", 67 + "properties": { 68 + "value": { 69 + "type": "integer" 70 + } 71 + } 72 + } 73 + } 74 + }
+30
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/binaryTypes.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "test.binary.types", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["cid", "data"], 8 + "properties": { 9 + "cid": { 10 + "type": "cid-link", 11 + "description": "Content identifier" 12 + }, 13 + "data": { 14 + "type": "bytes", 15 + "description": "Raw bytes", 16 + "maxLength": 5000 17 + }, 18 + "avatar": { 19 + "type": "blob", 20 + "accept": ["image/*"], 21 + "maxSize": 1000000, 22 + "description": "Profile avatar" 23 + }, 24 + "optionalCid": { 25 + "type": "cid-link" 26 + } 27 + } 28 + } 29 + } 30 + }
+45
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/constraints.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "test.constraints.validation", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "properties": { 8 + "username": { 9 + "type": "string", 10 + "minLength": 3, 11 + "maxLength": 20, 12 + "description": "User handle" 13 + }, 14 + "bio": { 15 + "type": "string", 16 + "maxGraphemes": 256, 17 + "minGraphemes": 1 18 + }, 19 + "age": { 20 + "type": "integer", 21 + "minimum": 13, 22 + "maximum": 120, 23 + "default": 18 24 + }, 25 + "enabled": { 26 + "type": "boolean", 27 + "default": false 28 + }, 29 + "tags": { 30 + "type": "array", 31 + "items": { 32 + "type": "string" 33 + }, 34 + "minLength": 0, 35 + "maxLength": 10 36 + }, 37 + "role": { 38 + "type": "string", 39 + "default": "user", 40 + "knownValues": ["user", "admin", "moderator"] 41 + } 42 + } 43 + } 44 + } 45 + }
+65
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/createRecord.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.createRecord", 4 + "defs": { 5 + "main": { 6 + "type": "procedure", 7 + "description": "Create a new record in a repository.", 8 + "input": { 9 + "encoding": "application/json", 10 + "schema": { 11 + "type": "object", 12 + "required": ["repo", "collection", "record"], 13 + "properties": { 14 + "repo": { 15 + "type": "string", 16 + "format": "at-identifier", 17 + "description": "The handle or DID of the repo" 18 + }, 19 + "collection": { 20 + "type": "string", 21 + "format": "nsid" 22 + }, 23 + "rkey": { 24 + "type": "string", 25 + "format": "record-key" 26 + }, 27 + "validate": { 28 + "type": "boolean", 29 + "default": true 30 + }, 31 + "record": { 32 + "type": "unknown", 33 + "description": "The record to create" 34 + }, 35 + "swapCommit": { 36 + "type": "string", 37 + "format": "cid" 38 + } 39 + } 40 + } 41 + }, 42 + "output": { 43 + "encoding": "application/json", 44 + "schema": { 45 + "type": "object", 46 + "required": ["uri", "cid"], 47 + "properties": { 48 + "uri": { 49 + "type": "string", 50 + "format": "at-uri" 51 + }, 52 + "cid": { 53 + "type": "string", 54 + "format": "cid" 55 + } 56 + } 57 + } 58 + }, 59 + "errors": [ 60 + {"name": "InvalidSwap"}, 61 + {"name": "InvalidRecord"} 62 + ] 63 + } 64 + } 65 + }
+156
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/defs.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.label.defs", 4 + "defs": { 5 + "label": { 6 + "type": "object", 7 + "description": "Metadata tag on an atproto resource (eg, repo or record).", 8 + "required": ["src", "uri", "val", "cts"], 9 + "properties": { 10 + "ver": { 11 + "type": "integer", 12 + "description": "The AT Protocol version of the label object." 13 + }, 14 + "src": { 15 + "type": "string", 16 + "format": "did", 17 + "description": "DID of the actor who created this label." 18 + }, 19 + "uri": { 20 + "type": "string", 21 + "format": "uri", 22 + "description": "AT URI of the record, repository (account), or other resource that this label applies to." 23 + }, 24 + "cid": { 25 + "type": "string", 26 + "format": "cid", 27 + "description": "Optionally, CID specifying the specific version of 'uri' resource this label applies to." 28 + }, 29 + "val": { 30 + "type": "string", 31 + "maxLength": 128, 32 + "description": "The short string name of the value or type of this label." 33 + }, 34 + "neg": { 35 + "type": "boolean", 36 + "description": "If true, this is a negation label, overwriting a previous label." 37 + }, 38 + "cts": { 39 + "type": "string", 40 + "format": "datetime", 41 + "description": "Timestamp when this label was created." 42 + }, 43 + "exp": { 44 + "type": "string", 45 + "format": "datetime", 46 + "description": "Timestamp at which this label expires (no longer applies)." 47 + }, 48 + "sig": { 49 + "type": "bytes", 50 + "description": "Signature of dag-cbor encoded label." 51 + } 52 + } 53 + }, 54 + "selfLabels": { 55 + "type": "object", 56 + "description": "Metadata tags on an atproto record, published by the author within the record.", 57 + "required": ["values"], 58 + "properties": { 59 + "values": { 60 + "type": "array", 61 + "items": { "type": "ref", "ref": "#selfLabel" }, 62 + "maxLength": 10 63 + } 64 + } 65 + }, 66 + "selfLabel": { 67 + "type": "object", 68 + "description": "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.", 69 + "required": ["val"], 70 + "properties": { 71 + "val": { 72 + "type": "string", 73 + "maxLength": 128, 74 + "description": "The short string name of the value or type of this label." 75 + } 76 + } 77 + }, 78 + "labelValueDefinition": { 79 + "type": "object", 80 + "description": "Declares a label value and its expected interpretations and behaviors.", 81 + "required": ["identifier", "severity", "blurs", "locales"], 82 + "properties": { 83 + "identifier": { 84 + "type": "string", 85 + "description": "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).", 86 + "maxLength": 100, 87 + "maxGraphemes": 100 88 + }, 89 + "severity": { 90 + "type": "string", 91 + "description": "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.", 92 + "knownValues": ["inform", "alert", "none"] 93 + }, 94 + "blurs": { 95 + "type": "string", 96 + "description": "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.", 97 + "knownValues": ["content", "media", "none"] 98 + }, 99 + "defaultSetting": { 100 + "type": "string", 101 + "description": "The default setting for this label.", 102 + "knownValues": ["ignore", "warn", "hide"], 103 + "default": "warn" 104 + }, 105 + "adultOnly": { 106 + "type": "boolean", 107 + "description": "Does the user need to have adult content enabled in order to configure this label?" 108 + }, 109 + "locales": { 110 + "type": "array", 111 + "items": { "type": "ref", "ref": "#labelValueDefinitionStrings" } 112 + } 113 + } 114 + }, 115 + "labelValueDefinitionStrings": { 116 + "type": "object", 117 + "description": "Strings which describe the label in the UI, localized into a specific language.", 118 + "required": ["lang", "name", "description"], 119 + "properties": { 120 + "lang": { 121 + "type": "string", 122 + "description": "The code of the language these strings are written in.", 123 + "format": "language" 124 + }, 125 + "name": { 126 + "type": "string", 127 + "description": "A short human-readable name for the label.", 128 + "maxGraphemes": 64, 129 + "maxLength": 640 130 + }, 131 + "description": { 132 + "type": "string", 133 + "description": "A longer description of what the label means and why it might be applied.", 134 + "maxGraphemes": 10000, 135 + "maxLength": 100000 136 + } 137 + } 138 + }, 139 + "labelValue": { 140 + "type": "string", 141 + "knownValues": [ 142 + "!hide", 143 + "!no-promote", 144 + "!warn", 145 + "!no-unauthenticated", 146 + "dmca-violation", 147 + "doxxing", 148 + "porn", 149 + "sexual", 150 + "nudity", 151 + "nsfl", 152 + "gore" 153 + ] 154 + } 155 + } 156 + }
+23
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/emptyObject.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "test.empty.object", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "properties": { 8 + "withEmpty": { 9 + "type": "ref", 10 + "ref": "#emptyDef" 11 + }, 12 + "normal": { 13 + "type": "string" 14 + } 15 + } 16 + }, 17 + "emptyDef": { 18 + "type": "object", 19 + "description": "Object with no properties - should generate Data<'a>", 20 + "properties": {} 21 + } 22 + } 23 + }
+51
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/external.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.embed.external", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "description": "A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post).", 8 + "required": ["external"], 9 + "properties": { 10 + "external": { 11 + "type": "ref", 12 + "ref": "#external" 13 + } 14 + } 15 + }, 16 + "external": { 17 + "type": "object", 18 + "required": ["uri", "title", "description"], 19 + "properties": { 20 + "uri": { "type": "string", "format": "uri" }, 21 + "title": { "type": "string" }, 22 + "description": { "type": "string" }, 23 + "thumb": { 24 + "type": "blob", 25 + "accept": ["image/*"], 26 + "maxSize": 1000000 27 + } 28 + } 29 + }, 30 + "view": { 31 + "type": "object", 32 + "required": ["external"], 33 + "properties": { 34 + "external": { 35 + "type": "ref", 36 + "ref": "#viewExternal" 37 + } 38 + } 39 + }, 40 + "viewExternal": { 41 + "type": "object", 42 + "required": ["uri", "title", "description"], 43 + "properties": { 44 + "uri": { "type": "string", "format": "uri" }, 45 + "title": { "type": "string" }, 46 + "description": { "type": "string" }, 47 + "thumb": { "type": "string", "format": "uri" } 48 + } 49 + } 50 + } 51 + }
+51
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/facet.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.richtext.facet", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "description": "Annotation of a sub-string within rich text.", 8 + "required": ["index", "features"], 9 + "properties": { 10 + "index": { "type": "ref", "ref": "#byteSlice" }, 11 + "features": { 12 + "type": "array", 13 + "items": { "type": "union", "refs": ["#mention", "#link", "#tag"] } 14 + } 15 + } 16 + }, 17 + "mention": { 18 + "type": "object", 19 + "description": "Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.", 20 + "required": ["did"], 21 + "properties": { 22 + "did": { "type": "string", "format": "did" } 23 + } 24 + }, 25 + "link": { 26 + "type": "object", 27 + "description": "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.", 28 + "required": ["uri"], 29 + "properties": { 30 + "uri": { "type": "string", "format": "uri" } 31 + } 32 + }, 33 + "tag": { 34 + "type": "object", 35 + "description": "Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').", 36 + "required": ["tag"], 37 + "properties": { 38 + "tag": { "type": "string", "maxLength": 640, "maxGraphemes": 64 } 39 + } 40 + }, 41 + "byteSlice": { 42 + "type": "object", 43 + "description": "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.", 44 + "required": ["byteStart", "byteEnd"], 45 + "properties": { 46 + "byteStart": { "type": "integer", "minimum": 0 }, 47 + "byteEnd": { "type": "integer", "minimum": 0 } 48 + } 49 + } 50 + } 51 + }
+58
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/getAuthorFeed.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.feed.getAuthorFeed", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "Get a view of an actor's 'author feed' (post and reposts by the author). Does not require auth.", 8 + "parameters": { 9 + "type": "params", 10 + "required": ["actor"], 11 + "properties": { 12 + "actor": { "type": "string", "format": "at-identifier" }, 13 + "limit": { 14 + "type": "integer", 15 + "minimum": 1, 16 + "maximum": 100, 17 + "default": 50 18 + }, 19 + "cursor": { "type": "string" }, 20 + "filter": { 21 + "type": "string", 22 + "description": "Combinations of post/repost types to include in response.", 23 + "knownValues": [ 24 + "posts_with_replies", 25 + "posts_no_replies", 26 + "posts_with_media", 27 + "posts_and_author_threads", 28 + "posts_with_video" 29 + ], 30 + "default": "posts_with_replies" 31 + }, 32 + "includePins": { 33 + "type": "boolean", 34 + "default": false 35 + } 36 + } 37 + }, 38 + "output": { 39 + "encoding": "application/json", 40 + "schema": { 41 + "type": "object", 42 + "required": ["feed"], 43 + "properties": { 44 + "cursor": { "type": "string" }, 45 + "feed": { 46 + "type": "array", 47 + "items": { 48 + "type": "ref", 49 + "ref": "app.bsky.feed.defs#feedViewPost" 50 + } 51 + } 52 + } 53 + } 54 + }, 55 + "errors": [{ "name": "BlockedActor" }, { "name": "BlockedByActor" }] 56 + } 57 + } 58 + }
+72
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/images.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.embed.images", 4 + "description": "A set of images embedded in a Bluesky record (eg, a post).", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["images"], 9 + "properties": { 10 + "images": { 11 + "type": "array", 12 + "items": { "type": "ref", "ref": "#image" }, 13 + "maxLength": 4 14 + } 15 + } 16 + }, 17 + "image": { 18 + "type": "object", 19 + "required": ["image", "alt"], 20 + "properties": { 21 + "image": { 22 + "type": "blob", 23 + "accept": ["image/*"], 24 + "maxSize": 1000000 25 + }, 26 + "alt": { 27 + "type": "string", 28 + "description": "Alt text description of the image, for accessibility." 29 + }, 30 + "aspectRatio": { 31 + "type": "ref", 32 + "ref": "app.bsky.embed.defs#aspectRatio" 33 + } 34 + } 35 + }, 36 + "view": { 37 + "type": "object", 38 + "required": ["images"], 39 + "properties": { 40 + "images": { 41 + "type": "array", 42 + "items": { "type": "ref", "ref": "#viewImage" }, 43 + "maxLength": 4 44 + } 45 + } 46 + }, 47 + "viewImage": { 48 + "type": "object", 49 + "required": ["thumb", "fullsize", "alt"], 50 + "properties": { 51 + "thumb": { 52 + "type": "string", 53 + "format": "uri", 54 + "description": "Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View." 55 + }, 56 + "fullsize": { 57 + "type": "string", 58 + "format": "uri", 59 + "description": "Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View." 60 + }, 61 + "alt": { 62 + "type": "string", 63 + "description": "Alt text description of the image, for accessibility." 64 + }, 65 + "aspectRatio": { 66 + "type": "ref", 67 + "ref": "app.bsky.embed.defs#aspectRatio" 68 + } 69 + } 70 + } 71 + } 72 + }
+58
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/multiDef.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.poll.definition", 4 + "defs": { 5 + "main": { 6 + "type": "record", 7 + "description": "Poll definition record", 8 + "key": "tid", 9 + "record": { 10 + "type": "object", 11 + "required": ["question", "options"], 12 + "properties": { 13 + "question": { 14 + "type": "string", 15 + "maxLength": 300 16 + }, 17 + "options": { 18 + "type": "array", 19 + "items": { 20 + "type": "ref", 21 + "ref": "#option" 22 + }, 23 + "minLength": 2, 24 + "maxLength": 4 25 + }, 26 + "endsAt": { 27 + "type": "string", 28 + "format": "datetime" 29 + } 30 + } 31 + } 32 + }, 33 + "option": { 34 + "type": "object", 35 + "required": ["text"], 36 + "properties": { 37 + "text": { 38 + "type": "string", 39 + "maxLength": 100 40 + } 41 + } 42 + }, 43 + "vote": { 44 + "type": "object", 45 + "required": ["pollRef", "optionIndex"], 46 + "properties": { 47 + "pollRef": { 48 + "type": "ref", 49 + "ref": "com.atproto.repo.strongRef" 50 + }, 51 + "optionIndex": { 52 + "type": "integer", 53 + "minimum": 0 54 + } 55 + } 56 + } 57 + } 58 + }
+7
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/not_a_lexicon.json
··· 1 + { 2 + "name": "some random config", 3 + "version": "1.0.0", 4 + "settings": { 5 + "enabled": true 6 + } 7 + }
+96
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/post.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.feed.post", 4 + "defs": { 5 + "main": { 6 + "type": "record", 7 + "description": "Record containing a Bluesky post.", 8 + "key": "tid", 9 + "record": { 10 + "type": "object", 11 + "required": ["text", "createdAt"], 12 + "properties": { 13 + "text": { 14 + "type": "string", 15 + "maxLength": 3000, 16 + "maxGraphemes": 300, 17 + "description": "The primary post content. May be an empty string, if there are embeds." 18 + }, 19 + "entities": { 20 + "type": "array", 21 + "description": "DEPRECATED: replaced by app.bsky.richtext.facet.", 22 + "items": { "type": "ref", "ref": "#entity" } 23 + }, 24 + "facets": { 25 + "type": "array", 26 + "description": "Annotations of text (mentions, URLs, hashtags, etc)", 27 + "items": { "type": "ref", "ref": "app.bsky.richtext.facet" } 28 + }, 29 + "reply": { "type": "ref", "ref": "#replyRef" }, 30 + "embed": { 31 + "type": "union", 32 + "refs": [ 33 + "app.bsky.embed.images", 34 + "app.bsky.embed.video", 35 + "app.bsky.embed.external", 36 + "app.bsky.embed.record", 37 + "app.bsky.embed.recordWithMedia" 38 + ] 39 + }, 40 + "langs": { 41 + "type": "array", 42 + "description": "Indicates human language of post primary text content.", 43 + "maxLength": 3, 44 + "items": { "type": "string", "format": "language" } 45 + }, 46 + "labels": { 47 + "type": "union", 48 + "description": "Self-label values for this post. Effectively content warnings.", 49 + "refs": ["com.atproto.label.defs#selfLabels"] 50 + }, 51 + "tags": { 52 + "type": "array", 53 + "description": "Additional hashtags, in addition to any included in post text and facets.", 54 + "maxLength": 8, 55 + "items": { "type": "string", "maxLength": 640, "maxGraphemes": 64 } 56 + }, 57 + "createdAt": { 58 + "type": "string", 59 + "format": "datetime", 60 + "description": "Client-declared timestamp when this post was originally created." 61 + } 62 + } 63 + } 64 + }, 65 + "replyRef": { 66 + "type": "object", 67 + "required": ["root", "parent"], 68 + "properties": { 69 + "root": { "type": "ref", "ref": "com.atproto.repo.strongRef" }, 70 + "parent": { "type": "ref", "ref": "com.atproto.repo.strongRef" } 71 + } 72 + }, 73 + "entity": { 74 + "type": "object", 75 + "description": "Deprecated: use facets instead.", 76 + "required": ["index", "type", "value"], 77 + "properties": { 78 + "index": { "type": "ref", "ref": "#textSlice" }, 79 + "type": { 80 + "type": "string", 81 + "description": "Expected values are 'mention' and 'link'." 82 + }, 83 + "value": { "type": "string" } 84 + } 85 + }, 86 + "textSlice": { 87 + "type": "object", 88 + "description": "Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings.", 89 + "required": ["start", "end"], 90 + "properties": { 91 + "start": { "type": "integer", "minimum": 0 }, 92 + "end": { "type": "integer", "minimum": 0 } 93 + } 94 + } 95 + } 96 + }
+96
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/record.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.embed.record", 4 + "description": "A representation of a record embedded in a Bluesky record (eg, a post). For example, a quote-post, or sharing a feed generator record.", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["record"], 9 + "properties": { 10 + "record": { "type": "ref", "ref": "com.atproto.repo.strongRef" } 11 + } 12 + }, 13 + "view": { 14 + "type": "object", 15 + "required": ["record"], 16 + "properties": { 17 + "record": { 18 + "type": "union", 19 + "refs": [ 20 + "#viewRecord", 21 + "#viewNotFound", 22 + "#viewBlocked", 23 + "#viewDetached", 24 + "app.bsky.feed.defs#generatorView", 25 + "app.bsky.graph.defs#listView", 26 + "app.bsky.labeler.defs#labelerView", 27 + "app.bsky.graph.defs#starterPackViewBasic" 28 + ] 29 + } 30 + } 31 + }, 32 + "viewRecord": { 33 + "type": "object", 34 + "required": ["uri", "cid", "author", "value", "indexedAt"], 35 + "properties": { 36 + "uri": { "type": "string", "format": "at-uri" }, 37 + "cid": { "type": "string", "format": "cid" }, 38 + "author": { 39 + "type": "ref", 40 + "ref": "app.bsky.actor.defs#profileViewBasic" 41 + }, 42 + "value": { 43 + "type": "unknown", 44 + "description": "The record data itself." 45 + }, 46 + "labels": { 47 + "type": "array", 48 + "items": { "type": "ref", "ref": "com.atproto.label.defs#label" } 49 + }, 50 + "replyCount": { "type": "integer" }, 51 + "repostCount": { "type": "integer" }, 52 + "likeCount": { "type": "integer" }, 53 + "quoteCount": { "type": "integer" }, 54 + "embeds": { 55 + "type": "array", 56 + "items": { 57 + "type": "union", 58 + "refs": [ 59 + "app.bsky.embed.images#view", 60 + "app.bsky.embed.video#view", 61 + "app.bsky.embed.external#view", 62 + "app.bsky.embed.record#view", 63 + "app.bsky.embed.recordWithMedia#view" 64 + ] 65 + } 66 + }, 67 + "indexedAt": { "type": "string", "format": "datetime" } 68 + } 69 + }, 70 + "viewNotFound": { 71 + "type": "object", 72 + "required": ["uri", "notFound"], 73 + "properties": { 74 + "uri": { "type": "string", "format": "at-uri" }, 75 + "notFound": { "type": "boolean", "const": true } 76 + } 77 + }, 78 + "viewBlocked": { 79 + "type": "object", 80 + "required": ["uri", "blocked", "author"], 81 + "properties": { 82 + "uri": { "type": "string", "format": "at-uri" }, 83 + "blocked": { "type": "boolean", "const": true }, 84 + "author": { "type": "ref", "ref": "app.bsky.feed.defs#blockedAuthor" } 85 + } 86 + }, 87 + "viewDetached": { 88 + "type": "object", 89 + "required": ["uri", "detached"], 90 + "properties": { 91 + "uri": { "type": "string", "format": "at-uri" }, 92 + "detached": { "type": "boolean", "const": true } 93 + } 94 + } 95 + } 96 + }
+43
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/recordWithMedia.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.embed.recordWithMedia", 4 + "description": "A representation of a record embedded in a Bluesky record (eg, a post), alongside other compatible embeds. For example, a quote post and image, or a quote post and external URL card.", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["record", "media"], 9 + "properties": { 10 + "record": { 11 + "type": "ref", 12 + "ref": "app.bsky.embed.record" 13 + }, 14 + "media": { 15 + "type": "union", 16 + "refs": [ 17 + "app.bsky.embed.images", 18 + "app.bsky.embed.video", 19 + "app.bsky.embed.external" 20 + ] 21 + } 22 + } 23 + }, 24 + "view": { 25 + "type": "object", 26 + "required": ["record", "media"], 27 + "properties": { 28 + "record": { 29 + "type": "ref", 30 + "ref": "app.bsky.embed.record#view" 31 + }, 32 + "media": { 33 + "type": "union", 34 + "refs": [ 35 + "app.bsky.embed.images#view", 36 + "app.bsky.embed.video#view", 37 + "app.bsky.embed.external#view" 38 + ] 39 + } 40 + } 41 + } 42 + } 43 + }
+15
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/strongRef.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.strongRef", 4 + "description": "A URI with a content-hash fingerprint.", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["uri", "cid"], 9 + "properties": { 10 + "uri": { "type": "string", "format": "at-uri" }, 11 + "cid": { "type": "string", "format": "cid" } 12 + } 13 + } 14 + } 15 + }
+126
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/subscribeRepos.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.sync.subscribeRepos", 4 + "defs": { 5 + "main": { 6 + "type": "subscription", 7 + "description": "Subscribe to repository update stream", 8 + "parameters": { 9 + "type": "params", 10 + "properties": { 11 + "cursor": { 12 + "type": "integer", 13 + "description": "The last known event seq number" 14 + } 15 + } 16 + }, 17 + "message": { 18 + "schema": { 19 + "type": "union", 20 + "refs": ["#commit", "#identity", "#account"] 21 + } 22 + } 23 + }, 24 + "commit": { 25 + "type": "object", 26 + "required": ["seq", "rebase", "tooBig", "repo", "commit", "rev", "since", "blocks", "ops", "blobs", "time"], 27 + "properties": { 28 + "seq": { 29 + "type": "integer" 30 + }, 31 + "rebase": { 32 + "type": "boolean" 33 + }, 34 + "tooBig": { 35 + "type": "boolean" 36 + }, 37 + "repo": { 38 + "type": "string", 39 + "format": "did" 40 + }, 41 + "commit": { 42 + "type": "cid-link" 43 + }, 44 + "rev": { 45 + "type": "string" 46 + }, 47 + "since": { 48 + "type": "string" 49 + }, 50 + "blocks": { 51 + "type": "bytes" 52 + }, 53 + "ops": { 54 + "type": "array", 55 + "items": { 56 + "type": "ref", 57 + "ref": "#repoOp" 58 + } 59 + }, 60 + "blobs": { 61 + "type": "array", 62 + "items": { 63 + "type": "cid-link" 64 + } 65 + }, 66 + "time": { 67 + "type": "string", 68 + "format": "datetime" 69 + } 70 + } 71 + }, 72 + "identity": { 73 + "type": "object", 74 + "required": ["seq", "did", "time"], 75 + "properties": { 76 + "seq": { 77 + "type": "integer" 78 + }, 79 + "did": { 80 + "type": "string", 81 + "format": "did" 82 + }, 83 + "time": { 84 + "type": "string", 85 + "format": "datetime" 86 + } 87 + } 88 + }, 89 + "account": { 90 + "type": "object", 91 + "required": ["seq", "did", "time", "active"], 92 + "properties": { 93 + "seq": { 94 + "type": "integer" 95 + }, 96 + "did": { 97 + "type": "string", 98 + "format": "did" 99 + }, 100 + "time": { 101 + "type": "string", 102 + "format": "datetime" 103 + }, 104 + "active": { 105 + "type": "boolean" 106 + } 107 + } 108 + }, 109 + "repoOp": { 110 + "type": "object", 111 + "required": ["action", "path", "cid"], 112 + "properties": { 113 + "action": { 114 + "type": "string", 115 + "knownValues": ["create", "update", "delete"] 116 + }, 117 + "path": { 118 + "type": "string" 119 + }, 120 + "cid": { 121 + "type": "cid-link" 122 + } 123 + } 124 + } 125 + } 126 + }
+56
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/token.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.embed.images", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["images"], 8 + "properties": { 9 + "images": { 10 + "type": "array", 11 + "items": { 12 + "type": "ref", 13 + "ref": "#image" 14 + }, 15 + "maxLength": 4 16 + } 17 + } 18 + }, 19 + "image": { 20 + "type": "object", 21 + "required": ["image", "alt"], 22 + "properties": { 23 + "image": { 24 + "type": "blob", 25 + "accept": ["image/png", "image/jpeg"], 26 + "maxSize": 1000000 27 + }, 28 + "alt": { 29 + "type": "string", 30 + "maxGraphemes": 10000 31 + }, 32 + "aspectRatio": { 33 + "type": "ref", 34 + "ref": "#aspectRatio" 35 + } 36 + } 37 + }, 38 + "aspectRatio": { 39 + "type": "object", 40 + "required": ["width", "height"], 41 + "properties": { 42 + "width": { 43 + "type": "integer", 44 + "minimum": 1 45 + }, 46 + "height": { 47 + "type": "integer", 48 + "minimum": 1 49 + } 50 + } 51 + }, 52 + "viewImage": { 53 + "type": "token" 54 + } 55 + } 56 + }
+67
crates/jacquard-codegen-tests/tests/fixtures/test_lexicons/video.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "app.bsky.embed.video", 4 + "description": "A video embedded in a Bluesky record (eg, a post).", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["video"], 9 + "properties": { 10 + "video": { 11 + "type": "blob", 12 + "description": "The mp4 video file. May be up to 100mb, formerly limited to 50mb.", 13 + "accept": ["video/mp4"], 14 + "maxSize": 100000000 15 + }, 16 + "captions": { 17 + "type": "array", 18 + "items": { "type": "ref", "ref": "#caption" }, 19 + "maxLength": 20 20 + }, 21 + "alt": { 22 + "type": "string", 23 + "description": "Alt text description of the video, for accessibility.", 24 + "maxGraphemes": 1000, 25 + "maxLength": 10000 26 + }, 27 + "aspectRatio": { 28 + "type": "ref", 29 + "ref": "app.bsky.embed.defs#aspectRatio" 30 + } 31 + } 32 + }, 33 + "caption": { 34 + "type": "object", 35 + "required": ["lang", "file"], 36 + "properties": { 37 + "lang": { 38 + "type": "string", 39 + "format": "language" 40 + }, 41 + "file": { 42 + "type": "blob", 43 + "accept": ["text/vtt"], 44 + "maxSize": 20000 45 + } 46 + } 47 + }, 48 + "view": { 49 + "type": "object", 50 + "required": ["cid", "playlist"], 51 + "properties": { 52 + "cid": { "type": "string", "format": "cid" }, 53 + "playlist": { "type": "string", "format": "uri" }, 54 + "thumbnail": { "type": "string", "format": "uri" }, 55 + "alt": { 56 + "type": "string", 57 + "maxGraphemes": 1000, 58 + "maxLength": 10000 59 + }, 60 + "aspectRatio": { 61 + "type": "ref", 62 + "ref": "app.bsky.embed.defs#aspectRatio" 63 + } 64 + } 65 + } 66 + } 67 + }
+1 -1
crates/jacquard-common/Cargo.toml
··· 2 2 name = "jacquard-common" 3 3 description = "Core AT Protocol types and utilities for Jacquard" 4 4 edition.workspace = true 5 - version = "0.12.0-beta.1" 5 + version = "0.12.0-beta.2" 6 6 authors.workspace = true 7 7 repository.workspace = true 8 8 keywords.workspace = true
+3 -3
crates/jacquard-derive/Cargo.toml
··· 16 16 17 17 [dependencies] 18 18 heck.workspace = true 19 - jacquard-lexicon = { version = "0.12.0-beta.1", path = "../jacquard-lexicon", features = ["codegen"] } 19 + jacquard-lexicon = { version = "0.12.0-beta.2", path = "../jacquard-lexicon", features = ["codegen"] } 20 20 proc-macro2.workspace = true 21 21 quote.workspace = true 22 22 syn.workspace = true 23 23 24 24 [dev-dependencies] 25 25 inventory = "0.3" 26 - jacquard-common = { version = "0.12.0-beta.1", path = "../jacquard-common" } 27 - jacquard-lexicon = { version = "0.12.0-beta.1", path = "../jacquard-lexicon" } 26 + jacquard-common = { version = "0.12.0-beta.2", path = "../jacquard-common" } 27 + jacquard-lexicon = { version = "0.12.0-beta.2", path = "../jacquard-lexicon" } 28 28 serde.workspace = true 29 29 serde_json.workspace = true 30 30 unicode-segmentation = "1.12"
+1 -1
crates/jacquard-identity/Cargo.toml
··· 1 1 [package] 2 2 name = "jacquard-identity" 3 3 edition.workspace = true 4 - version = "0.12.0-beta.1" 4 + version = "0.12.0-beta.2" 5 5 authors.workspace = true 6 6 repository.workspace = true 7 7 keywords.workspace = true
+5 -5
crates/jacquard-lexgen/Cargo.toml
··· 2 2 name = "jacquard-lexgen" 3 3 description = "Lexicon fetching and code generation binaries for Jacquard" 4 4 edition.workspace = true 5 - version = "0.12.0-beta.1" 5 + version = "0.12.0-beta.2" 6 6 authors.workspace = true 7 7 repository.workspace = true 8 8 keywords.workspace = true ··· 32 32 clap.workspace = true 33 33 glob = "0.3" 34 34 inventory = "0.3" 35 - jacquard-common = { version = "0.12.0-beta.1", features = [ "reqwest-client" ], path = "../jacquard-common" } 36 - jacquard-derive = { version = "0.12.0-beta.1", path = "../jacquard-derive" } 37 - jacquard-identity = { version = "0.12.0-beta.1", path = "../jacquard-identity", features = ["dns"] } 38 - jacquard-lexicon = { version = "0.12.0-beta.1", path = "../jacquard-lexicon" } 35 + jacquard-common = { version = "0.12.0-beta.2", features = [ "reqwest-client" ], path = "../jacquard-common" } 36 + jacquard-derive = { version = "0.12.0-beta.2", path = "../jacquard-derive" } 37 + jacquard-identity = { version = "0.12.0-beta.2", path = "../jacquard-identity", features = ["dns"] } 38 + jacquard-lexicon = { version = "0.12.0-beta.2", path = "../jacquard-lexicon" } 39 39 kdl = "6" 40 40 miette = { workspace = true, features = ["fancy"] } 41 41 reqwest = { workspace = true, features = ["json", "http2", "system-proxy", "rustls-tls"] }
+2 -3
crates/jacquard-lexicon/Cargo.toml
··· 2 2 name = "jacquard-lexicon" 3 3 description = "Lexicon schema parsing and code generation for Jacquard" 4 4 edition.workspace = true 5 - version = "0.12.0-beta.1" 5 + version = "0.12.0-beta.2" 6 6 authors.workspace = true 7 7 repository.workspace = true 8 8 keywords.workspace = true ··· 20 20 dashmap.workspace = true 21 21 heck = { workspace = true, optional = true } 22 22 inventory = "0.3" 23 - jacquard-common = { version = "0.12.0-beta.1", path = "../jacquard-common" } 23 + jacquard-common = { version = "0.12.0-beta.2", path = "../jacquard-common" } 24 24 miette = { workspace = true } 25 25 multihash.workspace = true 26 26 prettyplease = { workspace = true, optional = true } ··· 39 39 40 40 [dev-dependencies] 41 41 bytes = { workspace = true } 42 - jacquard-derive = { version = "0.12.0-beta.1", path = "../jacquard-derive"} 43 42 tempfile = { version = "3.23.0" }
crates/jacquard-lexicon/tests/fixtures/app_bsky_feed_post.rs crates/jacquard-codegen-tests/tests/fixtures/app_bsky_feed_post.rs
crates/jacquard-lexicon/tests/roundtrip_post.rs crates/jacquard-codegen-tests/tests/roundtrip_post.rs
crates/jacquard-lexicon/tests/union_test.rs crates/jacquard-codegen-tests/tests/union_test.rs
+4 -4
crates/jacquard-oauth/Cargo.toml
··· 1 1 [package] 2 2 name = "jacquard-oauth" 3 - version = "0.12.0-beta.1" 3 + version = "0.12.0-beta.2" 4 4 edition.workspace = true 5 5 description = "AT Protocol OAuth 2.1 core types and helpers for Jacquard" 6 6 authors.workspace = true ··· 22 22 scope-check = ["dep:jacquard-lexicon"] 23 23 24 24 [dependencies] 25 - jacquard-common = { version = "0.12.0-beta.1", path = "../jacquard-common", features = ["reqwest-client"] } 26 - jacquard-identity = { version = "0.12.0-beta.1", path = "../jacquard-identity" } 27 - jacquard-lexicon = { version = "0.12.0-beta.1", path = "../jacquard-lexicon", optional = true } 25 + jacquard-common = { version = "0.12.0-beta.2", path = "../jacquard-common", features = ["reqwest-client"] } 26 + jacquard-identity = { version = "0.12.0-beta.2", path = "../jacquard-identity" } 27 + jacquard-lexicon = { version = "0.12.0-beta.2", path = "../jacquard-lexicon", optional = true } 28 28 serde = { workspace = true, features = ["derive"] } 29 29 serde_json = { workspace = true } 30 30 smol_str = { workspace = true }
+68 -97
crates/jacquard-oauth/src/scopes.rs
··· 1 1 //! AT Protocol OAuth scopes 2 2 //! 3 - //! Derived from <https://tangled.org/smokesignal.events/atproto-identity-rs/raw/main/crates/atproto-oauth/src/scopes.rs> 3 + //! Originally derived from <https://tangled.org/nickgerakines.me/atproto-crates/raw/main/crates/atproto-oauth/src/scopes.rs>, since substantially modified. 4 4 //! 5 5 //! This module provides comprehensive support for AT Protocol OAuth scopes, 6 6 //! including parsing, serialization, normalization, and permission checking. ··· 36 36 use serde::de::{Error as DeError, Visitor}; 37 37 use serde::{Deserialize, Serialize}; 38 38 use smallvec::SmallVec; 39 - use smol_str::{SmolStr, ToSmolStr, format_smolstr}; 39 + use smol_str::{SmolStr, SmolStrBuilder, ToSmolStr, format_smolstr}; 40 40 41 41 /// Represents an AT Protocol OAuth scope 42 42 #[derive(Debug, Clone, PartialEq, Eq, Hash)] ··· 165 165 /// Include scope referencing a permission set NSID with optional audience. 166 166 /// 167 167 /// Represents `include:<nsid>[?aud=<did>]` scopes. The audience is a plain 168 - /// validated string — a DID optionally followed by `#fragment`. Stored in 168 + /// validated string - a DID optionally followed by `#fragment`. Stored in 169 169 /// decoded form; `#` is percent-encoded as `%23` on serialisation. 170 170 #[derive(Debug, Clone, PartialEq, Eq, Hash)] 171 171 pub struct IncludeScope<S: BosStr = DefaultStr> { ··· 241 241 /// Validate a MIME pattern string without allocating. 242 242 /// 243 243 /// Returns the pattern kind. Valid patterns: 244 - /// - `*/*` → `MimePatternKind::All` 245 - /// - `<type>/*` (e.g., `image/*`) → `MimePatternKind::TypeWildcard` 246 - /// - `<type>/<subtype>` (e.g., `image/png`) → `MimePatternKind::Exact` 244 + /// - `*/*` -> `MimePatternKind::All` 245 + /// - `<type>/*` (e.g., `image/*`) -> `MimePatternKind::TypeWildcard` 246 + /// - `<type>/<subtype>` (e.g., `image/png`) -> `MimePatternKind::Exact` 247 247 pub(crate) fn validate_mime_pattern(s: &str) -> Result<MimePatternKind, ParseError> { 248 248 if s == "*/*" { 249 249 Ok(MimePatternKind::All) ··· 251 251 let type_part = &s[..slash]; 252 252 let subtype_part = &s[slash + 1..]; 253 253 if type_part.is_empty() || subtype_part.is_empty() { 254 - return Err(ParseError::InvalidMimeType(s.to_string())); 254 + return Err(ParseError::InvalidMimeType(s.to_smolstr())); 255 255 } 256 256 if subtype_part == "*" { 257 257 Ok(MimePatternKind::TypeWildcard) ··· 259 259 Ok(MimePatternKind::Exact) 260 260 } 261 261 } else { 262 - Err(ParseError::InvalidMimeType(s.to_string())) 262 + Err(ParseError::InvalidMimeType(s.to_smolstr())) 263 263 } 264 264 } 265 265 ··· 290 290 /// 291 291 /// The caller must ensure `s` is a valid MIME pattern string 292 292 /// and `kind` matches the pattern. `MimePattern`'s API assumes 293 - /// the invariant holds — violating it will produce incorrect 293 + /// the invariant holds. Violating it will produce incorrect 294 294 /// results from downstream operations. 295 295 pub(crate) unsafe fn unchecked(s: S, kind: MimePatternKind) -> Self { 296 296 match kind { ··· 483 483 } 484 484 } 485 485 486 - // ============================================================================ 487 - // Scope index types — internal infrastructure for Phase 2's Scopes<S> container. 488 - // All types are pub(crate), consumed by the Scopes<S> container. 489 - // ============================================================================ 490 - 491 486 /// Byte-range indices for a single scope within a `Scopes` buffer. 492 487 #[derive(Debug, Clone, PartialEq, Eq)] 493 488 pub(crate) struct ScopeIndices { ··· 570 565 #[derive(Debug, Clone, PartialEq, Eq)] 571 566 pub(crate) enum IncludeAudience { 572 567 /// Audience in buffer is already decoded (no percent-encoding). 573 - /// `grants()` can compare directly. Serialisation must encode `#` → `%23`. 568 + /// `grants()` can compare directly. Serialisation must encode `#` -> `%23`. 574 569 Plain(u16, u16), 575 570 /// Audience in buffer contains percent-encoding (e.g., `%23`). 576 571 /// `grants()` must decode before comparing. Serialisation can pass through. 577 572 Encoded(u16, u16), 578 573 } 579 574 580 - // ============================================================================ 581 - // Scopes<S> container — validated, zero-copy scope string with indices. 582 - // ============================================================================ 583 - 584 575 /// Iterator over scopes in a `Scopes<S>` container. 585 - /// 586 - /// Yields `Scope<&'o str>` views that borrow from the shared buffer. 587 - /// This type is returned by `Scopes::iter()`. 588 576 pub struct ScopesIter<'i, 'o> { 589 577 buffer: &'o str, 590 578 indices: std::slice::Iter<'i, ScopeIndices>, ··· 647 635 // Check u16 limit on buffer length. 648 636 if s.len() > u16::MAX as usize { 649 637 return Err(ParseError::InvalidResource( 650 - "scope string exceeds u16 byte limit".to_string(), 638 + "scope string exceeds u16 byte limit".to_smolstr(), 651 639 )); 652 640 } 653 641 ··· 686 674 } 687 675 688 676 /// Iterate over scopes as `Scope<&'o str>` views borrowing from the buffer. 689 - /// 690 - /// The iterator borrows from the buffer via the `BorrowOrShare` split lifetimes. 691 - /// For example, when `S = &'a str`, the iterator yields `Scope<&'a str>` and 692 - /// can outlive the borrow of `self`. 693 677 pub fn iter<'i, 'o>(&'i self) -> ScopesIter<'i, 'o> 694 678 where 695 679 S: BorrowOrShare<'i, 'o, str>, ··· 732 716 } 733 717 734 718 /// Borrow as `Scopes<&str>`. 735 - /// 736 - /// Indices are cloned (they're small, no heap strings). The buffer 737 - /// is borrowed via `AsRef<str>`. 738 719 pub fn borrow(&self) -> Scopes<&str> { 739 720 Scopes { 740 721 buffer: self.buffer.as_ref(), ··· 743 724 } 744 725 745 726 /// Convert to `Scopes` with a different backing type. 746 - /// 747 - /// Indices are moved (no clone). The buffer is converted via `From<S>`. 748 - /// Byte offsets remain valid because the buffer content is identical. 749 727 pub fn convert<B: Bos<str> + AsRef<str> + From<S>>(self) -> Scopes<B> { 750 728 Scopes { 751 729 buffer: B::from(self.buffer), ··· 754 732 } 755 733 756 734 /// Produce the sorted, normalized space-separated scope string. 757 - /// 758 - /// Same output as `Serialize`, but returns `SmolStr` directly 759 - /// without going through a serializer. 760 735 pub fn to_normalized_string(&self) -> SmolStr { 761 736 if self.indices.is_empty() { 762 737 return SmolStr::default(); ··· 772 747 .collect(); 773 748 normalized.sort(); 774 749 775 - // Compute total length for pre-allocation. 776 - let total_len = normalized.iter().map(|s| s.len()).sum::<usize>() 777 - + if normalized.len() > 1 { 778 - normalized.len() - 1 779 - } else { 780 - 0 781 - }; // Add length for space separators. 782 - 783 - let mut result = String::with_capacity(total_len); 750 + let mut result = SmolStrBuilder::new(); 784 751 for (i, s) in normalized.iter().enumerate() { 785 752 if i > 0 { 786 753 result.push(' '); 787 754 } 788 755 result.push_str(s); 789 756 } 790 - result.to_smolstr() 757 + result.finish() 791 758 } 792 759 793 760 /// Check if the container has a scope that grants the given scope. ··· 837 804 } 838 805 } 839 806 840 - impl<S: Bos<str> + AsRef<str> + Default> Default for Scopes<S> { 807 + impl<S: Bos<str> + AsRef<str> + Default + FromStaticStr> Default for Scopes<S> { 841 808 fn default() -> Self { 809 + let buffer = S::from_static("atproto"); 810 + let end = (buffer.as_ref().len() - 1) as u16; 842 811 Scopes { 843 - buffer: S::default(), 844 - indices: Vec::new(), 812 + buffer, 813 + indices: vec![ScopeIndices { 814 + start: 0, 815 + end, 816 + inner: ScopeInnerIndices::Unit(ScopeKind::Atproto), 817 + }], 845 818 } 846 819 } 847 820 } ··· 901 874 } 902 875 903 876 let prefix = found_prefix.ok_or_else(|| { 904 - ParseError::UnknownPrefix(token[..token.find(':').unwrap_or(token.len())].to_string()) 877 + ParseError::UnknownPrefix(token[..token.find(':').unwrap_or(token.len())].to_smolstr()) 905 878 })?; 906 879 907 880 match prefix { ··· 916 889 "openid" => parse_openid_indices(suffix), 917 890 "profile" => parse_profile_indices(suffix), 918 891 "email" => parse_email_indices(suffix), 919 - _ => Err(ParseError::UnknownPrefix(prefix.to_string())), 892 + _ => Err(ParseError::UnknownPrefix(prefix.to_smolstr())), 920 893 } 921 894 } 922 895 ··· 937 910 "email" => AccountResource::Email, 938 911 "repo" => AccountResource::Repo, 939 912 "status" => AccountResource::Status, 940 - _ => return Err(ParseError::InvalidResource(resource_str.to_string())), 913 + _ => return Err(ParseError::InvalidResource(resource_str.to_smolstr())), 941 914 }; 942 915 943 916 let action = if let Some(params) = params { ··· 949 922 { 950 923 Some("read") => AccountAction::Read, 951 924 Some("manage") => AccountAction::Manage, 952 - Some(other) => return Err(ParseError::InvalidAction(other.to_string())), 925 + Some(other) => return Err(ParseError::InvalidAction(other.to_smolstr())), 953 926 None => AccountAction::Read, 954 927 } 955 928 } else { ··· 964 937 let scope = match suffix { 965 938 Some("handle") => IdentityScope::Handle, 966 939 Some("*") => IdentityScope::All, 967 - Some(other) => return Err(ParseError::InvalidResource(other.to_string())), 940 + Some(other) => return Err(ParseError::InvalidResource(other.to_smolstr())), 968 941 None => return Err(ParseError::MissingResource), 969 942 }; 970 943 ··· 977 950 Some("generic") => TransitionScope::Generic, 978 951 Some("email") => TransitionScope::Email, 979 952 Some("chat.bsky") => TransitionScope::ChatBsky, 980 - Some(other) => return Err(ParseError::InvalidResource(other.to_string())), 953 + Some(other) => return Err(ParseError::InvalidResource(other.to_smolstr())), 981 954 None => return Err(ParseError::MissingResource), 982 955 }; 983 956 ··· 988 961 fn parse_atproto_indices(suffix: Option<&str>) -> Result<ScopeInnerIndices, ParseError> { 989 962 if suffix.is_some() { 990 963 return Err(ParseError::InvalidResource( 991 - "atproto scope does not accept suffixes".to_string(), 964 + "atproto scope does not accept suffixes".to_smolstr(), 992 965 )); 993 966 } 994 967 Ok(ScopeInnerIndices::Unit(ScopeKind::Atproto)) ··· 998 971 fn parse_openid_indices(suffix: Option<&str>) -> Result<ScopeInnerIndices, ParseError> { 999 972 if suffix.is_some() { 1000 973 return Err(ParseError::InvalidResource( 1001 - "openid scope does not accept suffixes".to_string(), 974 + "openid scope does not accept suffixes".to_smolstr(), 1002 975 )); 1003 976 } 1004 977 Ok(ScopeInnerIndices::Unit(ScopeKind::OpenId)) ··· 1008 981 fn parse_profile_indices(suffix: Option<&str>) -> Result<ScopeInnerIndices, ParseError> { 1009 982 if suffix.is_some() { 1010 983 return Err(ParseError::InvalidResource( 1011 - "profile scope does not accept suffixes".to_string(), 984 + "profile scope does not accept suffixes".to_smolstr(), 1012 985 )); 1013 986 } 1014 987 Ok(ScopeInnerIndices::Unit(ScopeKind::Profile)) ··· 1018 991 fn parse_email_indices(suffix: Option<&str>) -> Result<ScopeInnerIndices, ParseError> { 1019 992 if suffix.is_some() { 1020 993 return Err(ParseError::InvalidResource( 1021 - "email scope does not accept suffixes".to_string(), 994 + "email scope does not accept suffixes".to_smolstr(), 1022 995 )); 1023 996 } 1024 997 Ok(ScopeInnerIndices::Unit(ScopeKind::Email)) ··· 1091 1064 let end = start + nsid_str.len() as u16; 1092 1065 Some((start, end)) 1093 1066 } else { 1094 - return Err(ParseError::InvalidResource(nsid_str.to_string())); 1067 + return Err(ParseError::InvalidResource(nsid_str.to_smolstr())); 1095 1068 } 1096 1069 } 1097 1070 }; ··· 1108 1081 "update" => flags |= RepoActionFlags::UPDATE, 1109 1082 "delete" => flags |= RepoActionFlags::DELETE, 1110 1083 "*" => flags = RepoActionFlags::ALL, 1111 - other => return Err(ParseError::InvalidAction(other.to_string())), 1084 + other => return Err(ParseError::InvalidAction(other.to_smolstr())), 1112 1085 } 1113 1086 } 1114 1087 actions = RepoActionFlags(flags); ··· 1252 1225 // Find the NSID's byte position in the token. 1253 1226 let nsid_pos = token 1254 1227 .find(nsid_str) 1255 - .ok_or_else(|| ParseError::InvalidResource(nsid_str.to_string()))?; 1228 + .ok_or_else(|| ParseError::InvalidResource(nsid_str.to_smolstr()))?; 1256 1229 let nsid_start = base + nsid_pos as u16; 1257 1230 let nsid_end = nsid_start + nsid_str.len() as u16; 1258 1231 ··· 1267 1240 // Validate and decode the percent-encoded value using fluent-uri. 1268 1241 let estr = EStr::<Query>::new(aud_value).ok_or_else(|| { 1269 1242 ParseError::InvalidResource( 1270 - "include audience has invalid percent-encoding".to_string(), 1243 + "include audience has invalid percent-encoding".to_smolstr(), 1271 1244 ) 1272 1245 })?; 1273 1246 1274 1247 let decoded = estr.decode().to_string().map_err(|_| { 1275 1248 ParseError::InvalidResource( 1276 - "include audience contains invalid UTF-8 sequence".to_string(), 1249 + "include audience contains invalid UTF-8 sequence".to_smolstr(), 1277 1250 ) 1278 1251 })?; 1279 1252 ··· 1284 1257 let frag = decoded.split('#').nth(1).unwrap_or(""); 1285 1258 if frag.is_empty() { 1286 1259 return Err(ParseError::InvalidResource( 1287 - "include audience fragment cannot be empty".to_string(), 1260 + "include audience fragment cannot be empty".to_smolstr(), 1288 1261 )); 1289 1262 } 1290 1263 } ··· 1296 1269 let frag = aud_value.split('#').nth(1).unwrap_or(""); 1297 1270 if frag.is_empty() { 1298 1271 return Err(ParseError::InvalidResource( 1299 - "include audience fragment cannot be empty".to_string(), 1272 + "include audience fragment cannot be empty".to_smolstr(), 1300 1273 )); 1301 1274 } 1302 1275 } ··· 1305 1278 // Find the audience's byte position in the token. 1306 1279 let aud_pos = token 1307 1280 .find(aud_value) 1308 - .ok_or_else(|| ParseError::InvalidResource(aud_value.to_string()))?; 1281 + .ok_or_else(|| ParseError::InvalidResource(aud_value.to_smolstr()))?; 1309 1282 let aud_start = base + aud_pos as u16; 1310 1283 let aud_end = aud_start + aud_value.len() as u16; 1311 1284 ··· 1612 1585 let prefix = found_prefix.ok_or_else(|| { 1613 1586 // If no known prefix found, extract what looks like a prefix for error reporting 1614 1587 let end = s.find(':').or_else(|| s.find('?')).unwrap_or(s.len()); 1615 - ParseError::UnknownPrefix(s[..end].to_string()) 1588 + ParseError::UnknownPrefix(s[..end].to_smolstr()) 1616 1589 })?; 1617 1590 1618 1591 match prefix { ··· 1626 1599 "openid" => Self::parse_openid(suffix), 1627 1600 "profile" => Self::parse_profile(suffix), 1628 1601 "email" => Self::parse_email(suffix), 1629 - _ => Err(ParseError::UnknownPrefix(prefix.to_string())), 1602 + _ => Err(ParseError::UnknownPrefix(prefix.to_smolstr())), 1630 1603 } 1631 1604 } 1632 1605 ··· 1646 1619 "email" => AccountResource::Email, 1647 1620 "repo" => AccountResource::Repo, 1648 1621 "status" => AccountResource::Status, 1649 - _ => return Err(ParseError::InvalidResource(resource_str.to_string())), 1622 + _ => return Err(ParseError::InvalidResource(resource_str.to_smolstr())), 1650 1623 }; 1651 1624 1652 1625 let action = if let Some(params) = params { ··· 1658 1631 { 1659 1632 Some("read") => AccountAction::Read, 1660 1633 Some("manage") => AccountAction::Manage, 1661 - Some(other) => return Err(ParseError::InvalidAction(other.to_string())), 1634 + Some(other) => return Err(ParseError::InvalidAction(other.to_smolstr())), 1662 1635 None => AccountAction::Read, 1663 1636 } 1664 1637 } else { ··· 1672 1645 let scope = match suffix { 1673 1646 Some("handle") => IdentityScope::Handle, 1674 1647 Some("*") => IdentityScope::All, 1675 - Some(other) => return Err(ParseError::InvalidResource(other.to_string())), 1648 + Some(other) => return Err(ParseError::InvalidResource(other.to_smolstr())), 1676 1649 None => return Err(ParseError::MissingResource), 1677 1650 }; 1678 1651 ··· 1750 1723 actions.insert(RepoAction::Update); 1751 1724 actions.insert(RepoAction::Delete); 1752 1725 } 1753 - other => return Err(ParseError::InvalidAction(other.to_string())), 1726 + other => return Err(ParseError::InvalidAction(other.to_smolstr())), 1754 1727 } 1755 1728 } 1756 1729 } ··· 1840 1813 fn parse_atproto(suffix: Option<&str>) -> Result<Self, ParseError> { 1841 1814 if suffix.is_some() { 1842 1815 return Err(ParseError::InvalidResource( 1843 - "atproto scope does not accept suffixes".to_string(), 1816 + "atproto scope does not accept suffixes".to_smolstr(), 1844 1817 )); 1845 1818 } 1846 1819 Ok(Scope::Atproto) ··· 1851 1824 Some("generic") => TransitionScope::Generic, 1852 1825 Some("email") => TransitionScope::Email, 1853 1826 Some("chat.bsky") => TransitionScope::ChatBsky, 1854 - Some(other) => return Err(ParseError::InvalidResource(other.to_string())), 1827 + Some(other) => return Err(ParseError::InvalidResource(other.to_smolstr())), 1855 1828 None => return Err(ParseError::MissingResource), 1856 1829 }; 1857 1830 ··· 1861 1834 fn parse_openid(suffix: Option<&str>) -> Result<Self, ParseError> { 1862 1835 if suffix.is_some() { 1863 1836 return Err(ParseError::InvalidResource( 1864 - "openid scope does not accept suffixes".to_string(), 1837 + "openid scope does not accept suffixes".to_smolstr(), 1865 1838 )); 1866 1839 } 1867 1840 Ok(Scope::OpenId) ··· 1870 1843 fn parse_profile(suffix: Option<&str>) -> Result<Self, ParseError> { 1871 1844 if suffix.is_some() { 1872 1845 return Err(ParseError::InvalidResource( 1873 - "profile scope does not accept suffixes".to_string(), 1846 + "profile scope does not accept suffixes".to_smolstr(), 1874 1847 )); 1875 1848 } 1876 1849 Ok(Scope::Profile) ··· 1879 1852 fn parse_email(suffix: Option<&str>) -> Result<Self, ParseError> { 1880 1853 if suffix.is_some() { 1881 1854 return Err(ParseError::InvalidResource( 1882 - "email scope does not accept suffixes".to_string(), 1855 + "email scope does not accept suffixes".to_smolstr(), 1883 1856 )); 1884 1857 } 1885 1858 Ok(Scope::Email) ··· 2029 2002 /// Check if this scope grants the permissions of another scope 2030 2003 pub fn grants<T: BosStr>(&self, other: &Scope<T>) -> bool { 2031 2004 match (self, other) { 2032 - // Atproto only grants itself (it's a required scope, not a permission grant) 2005 + // Atproto only grants itself 2033 2006 (Scope::Atproto, Scope::Atproto) => true, 2034 2007 (Scope::Atproto, _) => false, 2035 2008 // Nothing else grants atproto ··· 2090 2063 let collection_match = match (&a.collection, &b.collection) { 2091 2064 (RepoCollection::All, _) => true, 2092 2065 (RepoCollection::Nsid(a_nsid), RepoCollection::Nsid(b_nsid)) => { 2093 - // Compare as strings to support cross-type-parameter equality. 2094 2066 a_nsid.as_ref() == b_nsid.as_ref() 2095 2067 } 2096 2068 _ => false, ··· 2108 2080 } else { 2109 2081 b.lxm.iter().all(|b_lxm| match b_lxm { 2110 2082 RpcLexicon::All => false, 2111 - // Compare as strings to support cross-type-parameter equality. 2112 2083 RpcLexicon::Nsid(b_nsid) => a.lxm.iter().any(|a_lxm| match a_lxm { 2113 2084 RpcLexicon::All => false, 2114 2085 RpcLexicon::Nsid(a_nsid) => a_nsid.as_ref() == b_nsid.as_ref(), ··· 2121 2092 } else { 2122 2093 b.aud.iter().all(|b_aud| match b_aud { 2123 2094 RpcAudience::All => false, 2124 - // Compare as strings to support cross-type-parameter equality. 2125 2095 RpcAudience::Did(b_did) => a.aud.iter().any(|a_aud| match a_aud { 2126 2096 RpcAudience::All => false, 2127 2097 RpcAudience::Did(a_did) => a_did.as_ref() == b_did.as_ref(), ··· 2146 2116 } 2147 2117 (MimePattern::TypeWildcard(a_type), MimePattern::Exact(b_mime)) => b_mime 2148 2118 .as_ref() 2149 - .starts_with(&format!("{}/", a_type.as_ref())), 2119 + .starts_with(format_smolstr!("{}/", a_type.as_ref()).as_str()), 2150 2120 (MimePattern::Exact(a), MimePattern::Exact(b)) => a.as_ref() == b.as_ref(), 2151 2121 _ => false, 2152 2122 } ··· 2167 2137 } else if s.contains('/') { 2168 2138 Ok(MimePattern::Exact(S::from_str(s).unwrap())) 2169 2139 } else { 2170 - Err(ParseError::InvalidMimeType(s.to_string())) 2140 + Err(ParseError::InvalidMimeType(s.to_smolstr())) 2171 2141 } 2172 2142 } 2173 2143 } ··· 2183 2153 } else if s.contains('/') { 2184 2154 Ok(MimePattern::Exact(S::from(s))) 2185 2155 } else { 2186 - Err(ParseError::InvalidMimeType(s.to_string())) 2156 + Err(ParseError::InvalidMimeType(s.to_smolstr())) 2187 2157 } 2188 2158 } 2189 2159 } ··· 2218 2188 pub enum PermissionSetConversionError { 2219 2189 /// Unknown identity attribute in permission set 2220 2190 #[error("unknown identity attribute: {0}")] 2221 - UnknownIdentityAttr(String), 2191 + UnknownIdentityAttr(SmolStr), 2222 2192 2223 2193 /// Unknown account attribute in permission set 2224 2194 #[error("unknown account attribute: {0}")] 2225 - UnknownAccountAttr(String), 2195 + UnknownAccountAttr(SmolStr), 2226 2196 2227 2197 /// Invalid MIME pattern in blob permission 2228 2198 #[error("invalid MIME pattern: {0}")] 2229 - InvalidMimePattern(String), 2199 + InvalidMimePattern(SmolStr), 2230 2200 } 2231 2201 2232 2202 /// Error type for scope parsing ··· 2234 2204 #[non_exhaustive] 2235 2205 pub enum ParseError { 2236 2206 /// Unknown scope prefix 2237 - UnknownPrefix(String), 2207 + UnknownPrefix(SmolStr), 2238 2208 /// Missing required resource 2239 2209 MissingResource, 2240 2210 /// Invalid resource type 2241 - InvalidResource(String), 2211 + InvalidResource(SmolStr), 2242 2212 /// Invalid action type 2243 - InvalidAction(String), 2213 + InvalidAction(SmolStr), 2244 2214 /// Invalid MIME type 2245 - InvalidMimeType(String), 2215 + InvalidMimeType(SmolStr), 2246 2216 /// An AT Protocol string type (DID, NSID, etc.) failed validation during scope parsing. 2247 2217 ParseError(#[from] AtStrError), 2248 2218 } ··· 2347 2317 } 2348 2318 Err(_) => { 2349 2319 return Err(PermissionSetConversionError::InvalidMimePattern( 2350 - pattern_str.to_string(), 2320 + pattern_str.to_smolstr(), 2351 2321 )); 2352 2322 } 2353 2323 } ··· 2363 2333 "*" => IdentityScope::All, 2364 2334 other => { 2365 2335 return Err(PermissionSetConversionError::UnknownIdentityAttr( 2366 - other.to_string(), 2336 + other.to_smolstr(), 2367 2337 )); 2368 2338 } 2369 2339 }; ··· 2376 2346 "status" => AccountResource::Status, 2377 2347 other => { 2378 2348 return Err(PermissionSetConversionError::UnknownAccountAttr( 2379 - other.to_string(), 2349 + other.to_smolstr(), 2380 2350 )); 2381 2351 } 2382 2352 }; ··· 3676 3646 #[test] 3677 3647 fn test_scopes_default() { 3678 3648 // Test Default trait for Scopes. 3649 + // should return atproto scope 3679 3650 let default: Scopes<SmolStr> = Default::default(); 3680 - assert_eq!(default.len(), 0); 3681 - assert!(default.is_empty()); 3651 + assert_eq!(default.buffer.as_str(), "atproto"); 3652 + assert!(matches!(default.get(0), Some(Scope::Atproto))); 3682 3653 } 3683 3654 3684 3655 #[test]
+1 -1
crates/jacquard-repo/Cargo.toml
··· 2 2 name = "jacquard-repo" 3 3 description = "AT Protocol repository primitives: MST, commits, CAR I/O" 4 4 edition.workspace = true 5 - version = "0.12.0-beta.1" 5 + version = "0.12.0-beta.2" 6 6 authors.workspace = true 7 7 repository.workspace = true 8 8 keywords.workspace = true