Monorepo for Wisp.place. A static site hosting service built on top of the AT Protocol.
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: place.wisp.fs 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 jacquard_derive::IntoStatic 17)] 18#[serde(rename_all = "camelCase")] 19pub struct Directory<'a> { 20 #[serde(borrow)] 21 pub entries: Vec<crate::place_wisp::fs::Entry<'a>>, 22 #[serde(borrow)] 23 pub r#type: jacquard_common::CowStr<'a>, 24} 25 26pub mod directory_state { 27 28 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 29 #[allow(unused)] 30 use ::core::marker::PhantomData; 31 mod sealed { 32 pub trait Sealed {} 33 } 34 /// State trait tracking which required fields have been set 35 pub trait State: sealed::Sealed { 36 type Type; 37 type Entries; 38 } 39 /// Empty state - all required fields are unset 40 pub struct Empty(()); 41 impl sealed::Sealed for Empty {} 42 impl State for Empty { 43 type Type = Unset; 44 type Entries = Unset; 45 } 46 ///State transition - sets the `type` field to Set 47 pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>); 48 impl<S: State> sealed::Sealed for SetType<S> {} 49 impl<S: State> State for SetType<S> { 50 type Type = Set<members::r#type>; 51 type Entries = S::Entries; 52 } 53 ///State transition - sets the `entries` field to Set 54 pub struct SetEntries<S: State = Empty>(PhantomData<fn() -> S>); 55 impl<S: State> sealed::Sealed for SetEntries<S> {} 56 impl<S: State> State for SetEntries<S> { 57 type Type = S::Type; 58 type Entries = Set<members::entries>; 59 } 60 /// Marker types for field names 61 #[allow(non_camel_case_types)] 62 pub mod members { 63 ///Marker type for the `type` field 64 pub struct r#type(()); 65 ///Marker type for the `entries` field 66 pub struct entries(()); 67 } 68} 69 70/// Builder for constructing an instance of this type 71pub struct DirectoryBuilder<'a, S: directory_state::State> { 72 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 73 __unsafe_private_named: ( 74 ::core::option::Option<Vec<crate::place_wisp::fs::Entry<'a>>>, 75 ::core::option::Option<jacquard_common::CowStr<'a>>, 76 ), 77 _phantom: ::core::marker::PhantomData<&'a ()>, 78} 79 80impl<'a> Directory<'a> { 81 /// Create a new builder for this type 82 pub fn new() -> DirectoryBuilder<'a, directory_state::Empty> { 83 DirectoryBuilder::new() 84 } 85} 86 87impl<'a> DirectoryBuilder<'a, directory_state::Empty> { 88 /// Create a new builder with all fields unset 89 pub fn new() -> Self { 90 DirectoryBuilder { 91 _phantom_state: ::core::marker::PhantomData, 92 __unsafe_private_named: (None, None), 93 _phantom: ::core::marker::PhantomData, 94 } 95 } 96} 97 98impl<'a, S> DirectoryBuilder<'a, S> 99where 100 S: directory_state::State, 101 S::Entries: directory_state::IsUnset, 102{ 103 /// Set the `entries` field (required) 104 pub fn entries( 105 mut self, 106 value: impl Into<Vec<crate::place_wisp::fs::Entry<'a>>>, 107 ) -> DirectoryBuilder<'a, directory_state::SetEntries<S>> { 108 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 109 DirectoryBuilder { 110 _phantom_state: ::core::marker::PhantomData, 111 __unsafe_private_named: self.__unsafe_private_named, 112 _phantom: ::core::marker::PhantomData, 113 } 114 } 115} 116 117impl<'a, S> DirectoryBuilder<'a, S> 118where 119 S: directory_state::State, 120 S::Type: directory_state::IsUnset, 121{ 122 /// Set the `type` field (required) 123 pub fn r#type( 124 mut self, 125 value: impl Into<jacquard_common::CowStr<'a>>, 126 ) -> DirectoryBuilder<'a, directory_state::SetType<S>> { 127 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 128 DirectoryBuilder { 129 _phantom_state: ::core::marker::PhantomData, 130 __unsafe_private_named: self.__unsafe_private_named, 131 _phantom: ::core::marker::PhantomData, 132 } 133 } 134} 135 136impl<'a, S> DirectoryBuilder<'a, S> 137where 138 S: directory_state::State, 139 S::Type: directory_state::IsSet, 140 S::Entries: directory_state::IsSet, 141{ 142 /// Build the final struct 143 pub fn build(self) -> Directory<'a> { 144 Directory { 145 entries: self.__unsafe_private_named.0.unwrap(), 146 r#type: self.__unsafe_private_named.1.unwrap(), 147 extra_data: Default::default(), 148 } 149 } 150 /// Build the final struct with custom extra_data 151 pub fn build_with_data( 152 self, 153 extra_data: std::collections::BTreeMap< 154 jacquard_common::smol_str::SmolStr, 155 jacquard_common::types::value::Data<'a>, 156 >, 157 ) -> Directory<'a> { 158 Directory { 159 entries: self.__unsafe_private_named.0.unwrap(), 160 r#type: self.__unsafe_private_named.1.unwrap(), 161 extra_data: Some(extra_data), 162 } 163 } 164} 165 166fn lexicon_doc_place_wisp_fs() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 167 ::jacquard_lexicon::lexicon::LexiconDoc { 168 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 169 id: ::jacquard_common::CowStr::new_static("place.wisp.fs"), 170 revision: None, 171 description: None, 172 defs: { 173 let mut map = ::std::collections::BTreeMap::new(); 174 map.insert( 175 ::jacquard_common::smol_str::SmolStr::new_static("directory"), 176 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 177 description: None, 178 required: Some( 179 vec![ 180 ::jacquard_common::smol_str::SmolStr::new_static("type"), 181 ::jacquard_common::smol_str::SmolStr::new_static("entries") 182 ], 183 ), 184 nullable: None, 185 properties: { 186 #[allow(unused_mut)] 187 let mut map = ::std::collections::BTreeMap::new(); 188 map.insert( 189 ::jacquard_common::smol_str::SmolStr::new_static("entries"), 190 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 191 description: None, 192 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 193 description: None, 194 r#ref: ::jacquard_common::CowStr::new_static("#entry"), 195 }), 196 min_length: None, 197 max_length: Some(500usize), 198 }), 199 ); 200 map.insert( 201 ::jacquard_common::smol_str::SmolStr::new_static("type"), 202 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 203 description: None, 204 format: None, 205 default: None, 206 min_length: None, 207 max_length: None, 208 min_graphemes: None, 209 max_graphemes: None, 210 r#enum: None, 211 r#const: None, 212 known_values: None, 213 }), 214 ); 215 map 216 }, 217 }), 218 ); 219 map.insert( 220 ::jacquard_common::smol_str::SmolStr::new_static("entry"), 221 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 222 description: None, 223 required: Some( 224 vec![ 225 ::jacquard_common::smol_str::SmolStr::new_static("name"), 226 ::jacquard_common::smol_str::SmolStr::new_static("node") 227 ], 228 ), 229 nullable: None, 230 properties: { 231 #[allow(unused_mut)] 232 let mut map = ::std::collections::BTreeMap::new(); 233 map.insert( 234 ::jacquard_common::smol_str::SmolStr::new_static("name"), 235 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 236 description: None, 237 format: None, 238 default: None, 239 min_length: None, 240 max_length: Some(255usize), 241 min_graphemes: None, 242 max_graphemes: None, 243 r#enum: None, 244 r#const: None, 245 known_values: None, 246 }), 247 ); 248 map.insert( 249 ::jacquard_common::smol_str::SmolStr::new_static("node"), 250 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 251 description: None, 252 refs: vec![ 253 ::jacquard_common::CowStr::new_static("#file"), 254 ::jacquard_common::CowStr::new_static("#directory") 255 ], 256 closed: None, 257 }), 258 ); 259 map 260 }, 261 }), 262 ); 263 map.insert( 264 ::jacquard_common::smol_str::SmolStr::new_static("file"), 265 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 266 description: None, 267 required: Some( 268 vec![ 269 ::jacquard_common::smol_str::SmolStr::new_static("type"), 270 ::jacquard_common::smol_str::SmolStr::new_static("blob") 271 ], 272 ), 273 nullable: None, 274 properties: { 275 #[allow(unused_mut)] 276 let mut map = ::std::collections::BTreeMap::new(); 277 map.insert( 278 ::jacquard_common::smol_str::SmolStr::new_static("base64"), 279 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 280 description: None, 281 default: None, 282 r#const: None, 283 }), 284 ); 285 map.insert( 286 ::jacquard_common::smol_str::SmolStr::new_static("blob"), 287 ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { 288 description: None, 289 accept: None, 290 max_size: None, 291 }), 292 ); 293 map.insert( 294 ::jacquard_common::smol_str::SmolStr::new_static("encoding"), 295 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 296 description: Some( 297 ::jacquard_common::CowStr::new_static( 298 "Content encoding (e.g., gzip for compressed files)", 299 ), 300 ), 301 format: None, 302 default: None, 303 min_length: None, 304 max_length: None, 305 min_graphemes: None, 306 max_graphemes: None, 307 r#enum: None, 308 r#const: None, 309 known_values: None, 310 }), 311 ); 312 map.insert( 313 ::jacquard_common::smol_str::SmolStr::new_static("mimeType"), 314 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 315 description: Some( 316 ::jacquard_common::CowStr::new_static( 317 "Original MIME type before compression", 318 ), 319 ), 320 format: None, 321 default: None, 322 min_length: None, 323 max_length: None, 324 min_graphemes: None, 325 max_graphemes: None, 326 r#enum: None, 327 r#const: None, 328 known_values: None, 329 }), 330 ); 331 map.insert( 332 ::jacquard_common::smol_str::SmolStr::new_static("type"), 333 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 334 description: None, 335 format: None, 336 default: None, 337 min_length: None, 338 max_length: None, 339 min_graphemes: None, 340 max_graphemes: None, 341 r#enum: None, 342 r#const: None, 343 known_values: None, 344 }), 345 ); 346 map 347 }, 348 }), 349 ); 350 map.insert( 351 ::jacquard_common::smol_str::SmolStr::new_static("main"), 352 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { 353 description: Some( 354 ::jacquard_common::CowStr::new_static( 355 "Virtual filesystem manifest for a Wisp site", 356 ), 357 ), 358 key: None, 359 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { 360 description: None, 361 required: Some( 362 vec![ 363 ::jacquard_common::smol_str::SmolStr::new_static("site"), 364 ::jacquard_common::smol_str::SmolStr::new_static("root"), 365 ::jacquard_common::smol_str::SmolStr::new_static("createdAt") 366 ], 367 ), 368 nullable: None, 369 properties: { 370 #[allow(unused_mut)] 371 let mut map = ::std::collections::BTreeMap::new(); 372 map.insert( 373 ::jacquard_common::smol_str::SmolStr::new_static( 374 "createdAt", 375 ), 376 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 377 description: None, 378 format: Some( 379 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 380 ), 381 default: None, 382 min_length: None, 383 max_length: None, 384 min_graphemes: None, 385 max_graphemes: None, 386 r#enum: None, 387 r#const: None, 388 known_values: None, 389 }), 390 ); 391 map.insert( 392 ::jacquard_common::smol_str::SmolStr::new_static( 393 "fileCount", 394 ), 395 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 396 description: None, 397 default: None, 398 minimum: Some(0i64), 399 maximum: Some(1000i64), 400 r#enum: None, 401 r#const: None, 402 }), 403 ); 404 map.insert( 405 ::jacquard_common::smol_str::SmolStr::new_static("root"), 406 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 407 description: None, 408 r#ref: ::jacquard_common::CowStr::new_static("#directory"), 409 }), 410 ); 411 map.insert( 412 ::jacquard_common::smol_str::SmolStr::new_static("site"), 413 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 414 description: None, 415 format: None, 416 default: None, 417 min_length: None, 418 max_length: None, 419 min_graphemes: None, 420 max_graphemes: None, 421 r#enum: None, 422 r#const: None, 423 known_values: None, 424 }), 425 ); 426 map 427 }, 428 }), 429 }), 430 ); 431 map 432 }, 433 } 434} 435 436impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Directory<'a> { 437 fn nsid() -> &'static str { 438 "place.wisp.fs" 439 } 440 fn def_name() -> &'static str { 441 "directory" 442 } 443 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 444 lexicon_doc_place_wisp_fs() 445 } 446 fn validate( 447 &self, 448 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 449 { 450 let value = &self.entries; 451 #[allow(unused_comparisons)] 452 if value.len() > 500usize { 453 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 454 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 455 "entries", 456 ), 457 max: 500usize, 458 actual: value.len(), 459 }); 460 } 461 } 462 Ok(()) 463 } 464} 465 466#[jacquard_derive::lexicon] 467#[derive( 468 serde::Serialize, 469 serde::Deserialize, 470 Debug, 471 Clone, 472 PartialEq, 473 Eq, 474 jacquard_derive::IntoStatic 475)] 476#[serde(rename_all = "camelCase")] 477pub struct Entry<'a> { 478 #[serde(borrow)] 479 pub name: jacquard_common::CowStr<'a>, 480 #[serde(borrow)] 481 pub node: EntryNode<'a>, 482} 483 484pub mod entry_state { 485 486 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 487 #[allow(unused)] 488 use ::core::marker::PhantomData; 489 mod sealed { 490 pub trait Sealed {} 491 } 492 /// State trait tracking which required fields have been set 493 pub trait State: sealed::Sealed { 494 type Name; 495 type Node; 496 } 497 /// Empty state - all required fields are unset 498 pub struct Empty(()); 499 impl sealed::Sealed for Empty {} 500 impl State for Empty { 501 type Name = Unset; 502 type Node = Unset; 503 } 504 ///State transition - sets the `name` field to Set 505 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>); 506 impl<S: State> sealed::Sealed for SetName<S> {} 507 impl<S: State> State for SetName<S> { 508 type Name = Set<members::name>; 509 type Node = S::Node; 510 } 511 ///State transition - sets the `node` field to Set 512 pub struct SetNode<S: State = Empty>(PhantomData<fn() -> S>); 513 impl<S: State> sealed::Sealed for SetNode<S> {} 514 impl<S: State> State for SetNode<S> { 515 type Name = S::Name; 516 type Node = Set<members::node>; 517 } 518 /// Marker types for field names 519 #[allow(non_camel_case_types)] 520 pub mod members { 521 ///Marker type for the `name` field 522 pub struct name(()); 523 ///Marker type for the `node` field 524 pub struct node(()); 525 } 526} 527 528/// Builder for constructing an instance of this type 529pub struct EntryBuilder<'a, S: entry_state::State> { 530 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 531 __unsafe_private_named: ( 532 ::core::option::Option<jacquard_common::CowStr<'a>>, 533 ::core::option::Option<EntryNode<'a>>, 534 ), 535 _phantom: ::core::marker::PhantomData<&'a ()>, 536} 537 538impl<'a> Entry<'a> { 539 /// Create a new builder for this type 540 pub fn new() -> EntryBuilder<'a, entry_state::Empty> { 541 EntryBuilder::new() 542 } 543} 544 545impl<'a> EntryBuilder<'a, entry_state::Empty> { 546 /// Create a new builder with all fields unset 547 pub fn new() -> Self { 548 EntryBuilder { 549 _phantom_state: ::core::marker::PhantomData, 550 __unsafe_private_named: (None, None), 551 _phantom: ::core::marker::PhantomData, 552 } 553 } 554} 555 556impl<'a, S> EntryBuilder<'a, S> 557where 558 S: entry_state::State, 559 S::Name: entry_state::IsUnset, 560{ 561 /// Set the `name` field (required) 562 pub fn name( 563 mut self, 564 value: impl Into<jacquard_common::CowStr<'a>>, 565 ) -> EntryBuilder<'a, entry_state::SetName<S>> { 566 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 567 EntryBuilder { 568 _phantom_state: ::core::marker::PhantomData, 569 __unsafe_private_named: self.__unsafe_private_named, 570 _phantom: ::core::marker::PhantomData, 571 } 572 } 573} 574 575impl<'a, S> EntryBuilder<'a, S> 576where 577 S: entry_state::State, 578 S::Node: entry_state::IsUnset, 579{ 580 /// Set the `node` field (required) 581 pub fn node( 582 mut self, 583 value: impl Into<EntryNode<'a>>, 584 ) -> EntryBuilder<'a, entry_state::SetNode<S>> { 585 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 586 EntryBuilder { 587 _phantom_state: ::core::marker::PhantomData, 588 __unsafe_private_named: self.__unsafe_private_named, 589 _phantom: ::core::marker::PhantomData, 590 } 591 } 592} 593 594impl<'a, S> EntryBuilder<'a, S> 595where 596 S: entry_state::State, 597 S::Name: entry_state::IsSet, 598 S::Node: entry_state::IsSet, 599{ 600 /// Build the final struct 601 pub fn build(self) -> Entry<'a> { 602 Entry { 603 name: self.__unsafe_private_named.0.unwrap(), 604 node: self.__unsafe_private_named.1.unwrap(), 605 extra_data: Default::default(), 606 } 607 } 608 /// Build the final struct with custom extra_data 609 pub fn build_with_data( 610 self, 611 extra_data: std::collections::BTreeMap< 612 jacquard_common::smol_str::SmolStr, 613 jacquard_common::types::value::Data<'a>, 614 >, 615 ) -> Entry<'a> { 616 Entry { 617 name: self.__unsafe_private_named.0.unwrap(), 618 node: self.__unsafe_private_named.1.unwrap(), 619 extra_data: Some(extra_data), 620 } 621 } 622} 623 624#[jacquard_derive::open_union] 625#[derive( 626 serde::Serialize, 627 serde::Deserialize, 628 Debug, 629 Clone, 630 PartialEq, 631 Eq, 632 jacquard_derive::IntoStatic 633)] 634#[serde(tag = "$type")] 635#[serde(bound(deserialize = "'de: 'a"))] 636pub enum EntryNode<'a> { 637 #[serde(rename = "place.wisp.fs#file")] 638 File(Box<crate::place_wisp::fs::File<'a>>), 639 #[serde(rename = "place.wisp.fs#directory")] 640 Directory(Box<crate::place_wisp::fs::Directory<'a>>), 641} 642 643impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Entry<'a> { 644 fn nsid() -> &'static str { 645 "place.wisp.fs" 646 } 647 fn def_name() -> &'static str { 648 "entry" 649 } 650 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 651 lexicon_doc_place_wisp_fs() 652 } 653 fn validate( 654 &self, 655 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 656 { 657 let value = &self.name; 658 #[allow(unused_comparisons)] 659 if <str>::len(value.as_ref()) > 255usize { 660 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 661 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 662 "name", 663 ), 664 max: 255usize, 665 actual: <str>::len(value.as_ref()), 666 }); 667 } 668 } 669 Ok(()) 670 } 671} 672 673#[jacquard_derive::lexicon] 674#[derive( 675 serde::Serialize, 676 serde::Deserialize, 677 Debug, 678 Clone, 679 PartialEq, 680 Eq, 681 jacquard_derive::IntoStatic 682)] 683#[serde(rename_all = "camelCase")] 684pub struct File<'a> { 685 /// True if blob content is base64-encoded (used to bypass PDS content sniffing) 686 #[serde(skip_serializing_if = "std::option::Option::is_none")] 687 pub base64: Option<bool>, 688 /// Content blob ref 689 #[serde(borrow)] 690 pub blob: jacquard_common::types::blob::BlobRef<'a>, 691 /// Content encoding (e.g., gzip for compressed files) 692 #[serde(skip_serializing_if = "std::option::Option::is_none")] 693 #[serde(borrow)] 694 pub encoding: Option<jacquard_common::CowStr<'a>>, 695 /// Original MIME type before compression 696 #[serde(skip_serializing_if = "std::option::Option::is_none")] 697 #[serde(borrow)] 698 pub mime_type: Option<jacquard_common::CowStr<'a>>, 699 #[serde(borrow)] 700 pub r#type: jacquard_common::CowStr<'a>, 701} 702 703pub mod file_state { 704 705 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 706 #[allow(unused)] 707 use ::core::marker::PhantomData; 708 mod sealed { 709 pub trait Sealed {} 710 } 711 /// State trait tracking which required fields have been set 712 pub trait State: sealed::Sealed { 713 type Type; 714 type Blob; 715 } 716 /// Empty state - all required fields are unset 717 pub struct Empty(()); 718 impl sealed::Sealed for Empty {} 719 impl State for Empty { 720 type Type = Unset; 721 type Blob = Unset; 722 } 723 ///State transition - sets the `type` field to Set 724 pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>); 725 impl<S: State> sealed::Sealed for SetType<S> {} 726 impl<S: State> State for SetType<S> { 727 type Type = Set<members::r#type>; 728 type Blob = S::Blob; 729 } 730 ///State transition - sets the `blob` field to Set 731 pub struct SetBlob<S: State = Empty>(PhantomData<fn() -> S>); 732 impl<S: State> sealed::Sealed for SetBlob<S> {} 733 impl<S: State> State for SetBlob<S> { 734 type Type = S::Type; 735 type Blob = Set<members::blob>; 736 } 737 /// Marker types for field names 738 #[allow(non_camel_case_types)] 739 pub mod members { 740 ///Marker type for the `type` field 741 pub struct r#type(()); 742 ///Marker type for the `blob` field 743 pub struct blob(()); 744 } 745} 746 747/// Builder for constructing an instance of this type 748pub struct FileBuilder<'a, S: file_state::State> { 749 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 750 __unsafe_private_named: ( 751 ::core::option::Option<bool>, 752 ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>, 753 ::core::option::Option<jacquard_common::CowStr<'a>>, 754 ::core::option::Option<jacquard_common::CowStr<'a>>, 755 ::core::option::Option<jacquard_common::CowStr<'a>>, 756 ), 757 _phantom: ::core::marker::PhantomData<&'a ()>, 758} 759 760impl<'a> File<'a> { 761 /// Create a new builder for this type 762 pub fn new() -> FileBuilder<'a, file_state::Empty> { 763 FileBuilder::new() 764 } 765} 766 767impl<'a> FileBuilder<'a, file_state::Empty> { 768 /// Create a new builder with all fields unset 769 pub fn new() -> Self { 770 FileBuilder { 771 _phantom_state: ::core::marker::PhantomData, 772 __unsafe_private_named: (None, None, None, None, None), 773 _phantom: ::core::marker::PhantomData, 774 } 775 } 776} 777 778impl<'a, S: file_state::State> FileBuilder<'a, S> { 779 /// Set the `base64` field (optional) 780 pub fn base64(mut self, value: impl Into<Option<bool>>) -> Self { 781 self.__unsafe_private_named.0 = value.into(); 782 self 783 } 784 /// Set the `base64` field to an Option value (optional) 785 pub fn maybe_base64(mut self, value: Option<bool>) -> Self { 786 self.__unsafe_private_named.0 = value; 787 self 788 } 789} 790 791impl<'a, S> FileBuilder<'a, S> 792where 793 S: file_state::State, 794 S::Blob: file_state::IsUnset, 795{ 796 /// Set the `blob` field (required) 797 pub fn blob( 798 mut self, 799 value: impl Into<jacquard_common::types::blob::BlobRef<'a>>, 800 ) -> FileBuilder<'a, file_state::SetBlob<S>> { 801 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 802 FileBuilder { 803 _phantom_state: ::core::marker::PhantomData, 804 __unsafe_private_named: self.__unsafe_private_named, 805 _phantom: ::core::marker::PhantomData, 806 } 807 } 808} 809 810impl<'a, S: file_state::State> FileBuilder<'a, S> { 811 /// Set the `encoding` field (optional) 812 pub fn encoding( 813 mut self, 814 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 815 ) -> Self { 816 self.__unsafe_private_named.2 = value.into(); 817 self 818 } 819 /// Set the `encoding` field to an Option value (optional) 820 pub fn maybe_encoding(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 821 self.__unsafe_private_named.2 = value; 822 self 823 } 824} 825 826impl<'a, S: file_state::State> FileBuilder<'a, S> { 827 /// Set the `mimeType` field (optional) 828 pub fn mime_type( 829 mut self, 830 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 831 ) -> Self { 832 self.__unsafe_private_named.3 = value.into(); 833 self 834 } 835 /// Set the `mimeType` field to an Option value (optional) 836 pub fn maybe_mime_type( 837 mut self, 838 value: Option<jacquard_common::CowStr<'a>>, 839 ) -> Self { 840 self.__unsafe_private_named.3 = value; 841 self 842 } 843} 844 845impl<'a, S> FileBuilder<'a, S> 846where 847 S: file_state::State, 848 S::Type: file_state::IsUnset, 849{ 850 /// Set the `type` field (required) 851 pub fn r#type( 852 mut self, 853 value: impl Into<jacquard_common::CowStr<'a>>, 854 ) -> FileBuilder<'a, file_state::SetType<S>> { 855 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 856 FileBuilder { 857 _phantom_state: ::core::marker::PhantomData, 858 __unsafe_private_named: self.__unsafe_private_named, 859 _phantom: ::core::marker::PhantomData, 860 } 861 } 862} 863 864impl<'a, S> FileBuilder<'a, S> 865where 866 S: file_state::State, 867 S::Type: file_state::IsSet, 868 S::Blob: file_state::IsSet, 869{ 870 /// Build the final struct 871 pub fn build(self) -> File<'a> { 872 File { 873 base64: self.__unsafe_private_named.0, 874 blob: self.__unsafe_private_named.1.unwrap(), 875 encoding: self.__unsafe_private_named.2, 876 mime_type: self.__unsafe_private_named.3, 877 r#type: self.__unsafe_private_named.4.unwrap(), 878 extra_data: Default::default(), 879 } 880 } 881 /// Build the final struct with custom extra_data 882 pub fn build_with_data( 883 self, 884 extra_data: std::collections::BTreeMap< 885 jacquard_common::smol_str::SmolStr, 886 jacquard_common::types::value::Data<'a>, 887 >, 888 ) -> File<'a> { 889 File { 890 base64: self.__unsafe_private_named.0, 891 blob: self.__unsafe_private_named.1.unwrap(), 892 encoding: self.__unsafe_private_named.2, 893 mime_type: self.__unsafe_private_named.3, 894 r#type: self.__unsafe_private_named.4.unwrap(), 895 extra_data: Some(extra_data), 896 } 897 } 898} 899 900impl<'a> ::jacquard_lexicon::schema::LexiconSchema for File<'a> { 901 fn nsid() -> &'static str { 902 "place.wisp.fs" 903 } 904 fn def_name() -> &'static str { 905 "file" 906 } 907 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 908 lexicon_doc_place_wisp_fs() 909 } 910 fn validate( 911 &self, 912 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 913 Ok(()) 914 } 915} 916 917/// Virtual filesystem manifest for a Wisp site 918#[jacquard_derive::lexicon] 919#[derive( 920 serde::Serialize, 921 serde::Deserialize, 922 Debug, 923 Clone, 924 PartialEq, 925 Eq, 926 jacquard_derive::IntoStatic 927)] 928#[serde(rename_all = "camelCase")] 929pub struct Fs<'a> { 930 pub created_at: jacquard_common::types::string::Datetime, 931 #[serde(skip_serializing_if = "std::option::Option::is_none")] 932 pub file_count: Option<i64>, 933 #[serde(borrow)] 934 pub root: crate::place_wisp::fs::Directory<'a>, 935 #[serde(borrow)] 936 pub site: jacquard_common::CowStr<'a>, 937} 938 939pub mod fs_state { 940 941 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 942 #[allow(unused)] 943 use ::core::marker::PhantomData; 944 mod sealed { 945 pub trait Sealed {} 946 } 947 /// State trait tracking which required fields have been set 948 pub trait State: sealed::Sealed { 949 type Site; 950 type Root; 951 type CreatedAt; 952 } 953 /// Empty state - all required fields are unset 954 pub struct Empty(()); 955 impl sealed::Sealed for Empty {} 956 impl State for Empty { 957 type Site = Unset; 958 type Root = Unset; 959 type CreatedAt = Unset; 960 } 961 ///State transition - sets the `site` field to Set 962 pub struct SetSite<S: State = Empty>(PhantomData<fn() -> S>); 963 impl<S: State> sealed::Sealed for SetSite<S> {} 964 impl<S: State> State for SetSite<S> { 965 type Site = Set<members::site>; 966 type Root = S::Root; 967 type CreatedAt = S::CreatedAt; 968 } 969 ///State transition - sets the `root` field to Set 970 pub struct SetRoot<S: State = Empty>(PhantomData<fn() -> S>); 971 impl<S: State> sealed::Sealed for SetRoot<S> {} 972 impl<S: State> State for SetRoot<S> { 973 type Site = S::Site; 974 type Root = Set<members::root>; 975 type CreatedAt = S::CreatedAt; 976 } 977 ///State transition - sets the `created_at` field to Set 978 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 979 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 980 impl<S: State> State for SetCreatedAt<S> { 981 type Site = S::Site; 982 type Root = S::Root; 983 type CreatedAt = Set<members::created_at>; 984 } 985 /// Marker types for field names 986 #[allow(non_camel_case_types)] 987 pub mod members { 988 ///Marker type for the `site` field 989 pub struct site(()); 990 ///Marker type for the `root` field 991 pub struct root(()); 992 ///Marker type for the `created_at` field 993 pub struct created_at(()); 994 } 995} 996 997/// Builder for constructing an instance of this type 998pub struct FsBuilder<'a, S: fs_state::State> { 999 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 1000 __unsafe_private_named: ( 1001 ::core::option::Option<jacquard_common::types::string::Datetime>, 1002 ::core::option::Option<i64>, 1003 ::core::option::Option<crate::place_wisp::fs::Directory<'a>>, 1004 ::core::option::Option<jacquard_common::CowStr<'a>>, 1005 ), 1006 _phantom: ::core::marker::PhantomData<&'a ()>, 1007} 1008 1009impl<'a> Fs<'a> { 1010 /// Create a new builder for this type 1011 pub fn new() -> FsBuilder<'a, fs_state::Empty> { 1012 FsBuilder::new() 1013 } 1014} 1015 1016impl<'a> FsBuilder<'a, fs_state::Empty> { 1017 /// Create a new builder with all fields unset 1018 pub fn new() -> Self { 1019 FsBuilder { 1020 _phantom_state: ::core::marker::PhantomData, 1021 __unsafe_private_named: (None, None, None, None), 1022 _phantom: ::core::marker::PhantomData, 1023 } 1024 } 1025} 1026 1027impl<'a, S> FsBuilder<'a, S> 1028where 1029 S: fs_state::State, 1030 S::CreatedAt: fs_state::IsUnset, 1031{ 1032 /// Set the `createdAt` field (required) 1033 pub fn created_at( 1034 mut self, 1035 value: impl Into<jacquard_common::types::string::Datetime>, 1036 ) -> FsBuilder<'a, fs_state::SetCreatedAt<S>> { 1037 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 1038 FsBuilder { 1039 _phantom_state: ::core::marker::PhantomData, 1040 __unsafe_private_named: self.__unsafe_private_named, 1041 _phantom: ::core::marker::PhantomData, 1042 } 1043 } 1044} 1045 1046impl<'a, S: fs_state::State> FsBuilder<'a, S> { 1047 /// Set the `fileCount` field (optional) 1048 pub fn file_count(mut self, value: impl Into<Option<i64>>) -> Self { 1049 self.__unsafe_private_named.1 = value.into(); 1050 self 1051 } 1052 /// Set the `fileCount` field to an Option value (optional) 1053 pub fn maybe_file_count(mut self, value: Option<i64>) -> Self { 1054 self.__unsafe_private_named.1 = value; 1055 self 1056 } 1057} 1058 1059impl<'a, S> FsBuilder<'a, S> 1060where 1061 S: fs_state::State, 1062 S::Root: fs_state::IsUnset, 1063{ 1064 /// Set the `root` field (required) 1065 pub fn root( 1066 mut self, 1067 value: impl Into<crate::place_wisp::fs::Directory<'a>>, 1068 ) -> FsBuilder<'a, fs_state::SetRoot<S>> { 1069 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 1070 FsBuilder { 1071 _phantom_state: ::core::marker::PhantomData, 1072 __unsafe_private_named: self.__unsafe_private_named, 1073 _phantom: ::core::marker::PhantomData, 1074 } 1075 } 1076} 1077 1078impl<'a, S> FsBuilder<'a, S> 1079where 1080 S: fs_state::State, 1081 S::Site: fs_state::IsUnset, 1082{ 1083 /// Set the `site` field (required) 1084 pub fn site( 1085 mut self, 1086 value: impl Into<jacquard_common::CowStr<'a>>, 1087 ) -> FsBuilder<'a, fs_state::SetSite<S>> { 1088 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 1089 FsBuilder { 1090 _phantom_state: ::core::marker::PhantomData, 1091 __unsafe_private_named: self.__unsafe_private_named, 1092 _phantom: ::core::marker::PhantomData, 1093 } 1094 } 1095} 1096 1097impl<'a, S> FsBuilder<'a, S> 1098where 1099 S: fs_state::State, 1100 S::Site: fs_state::IsSet, 1101 S::Root: fs_state::IsSet, 1102 S::CreatedAt: fs_state::IsSet, 1103{ 1104 /// Build the final struct 1105 pub fn build(self) -> Fs<'a> { 1106 Fs { 1107 created_at: self.__unsafe_private_named.0.unwrap(), 1108 file_count: self.__unsafe_private_named.1, 1109 root: self.__unsafe_private_named.2.unwrap(), 1110 site: self.__unsafe_private_named.3.unwrap(), 1111 extra_data: Default::default(), 1112 } 1113 } 1114 /// Build the final struct with custom extra_data 1115 pub fn build_with_data( 1116 self, 1117 extra_data: std::collections::BTreeMap< 1118 jacquard_common::smol_str::SmolStr, 1119 jacquard_common::types::value::Data<'a>, 1120 >, 1121 ) -> Fs<'a> { 1122 Fs { 1123 created_at: self.__unsafe_private_named.0.unwrap(), 1124 file_count: self.__unsafe_private_named.1, 1125 root: self.__unsafe_private_named.2.unwrap(), 1126 site: self.__unsafe_private_named.3.unwrap(), 1127 extra_data: Some(extra_data), 1128 } 1129 } 1130} 1131 1132impl<'a> Fs<'a> { 1133 pub fn uri( 1134 uri: impl Into<jacquard_common::CowStr<'a>>, 1135 ) -> Result< 1136 jacquard_common::types::uri::RecordUri<'a, FsRecord>, 1137 jacquard_common::types::uri::UriError, 1138 > { 1139 jacquard_common::types::uri::RecordUri::try_from_uri( 1140 jacquard_common::types::string::AtUri::new_cow(uri.into())?, 1141 ) 1142 } 1143} 1144 1145/// Typed wrapper for GetRecord response with this collection's record type. 1146#[derive( 1147 serde::Serialize, 1148 serde::Deserialize, 1149 Debug, 1150 Clone, 1151 PartialEq, 1152 Eq, 1153 jacquard_derive::IntoStatic 1154)] 1155#[serde(rename_all = "camelCase")] 1156pub struct FsGetRecordOutput<'a> { 1157 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1158 #[serde(borrow)] 1159 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>, 1160 #[serde(borrow)] 1161 pub uri: jacquard_common::types::string::AtUri<'a>, 1162 #[serde(borrow)] 1163 pub value: Fs<'a>, 1164} 1165 1166impl From<FsGetRecordOutput<'_>> for Fs<'_> { 1167 fn from(output: FsGetRecordOutput<'_>) -> Self { 1168 use jacquard_common::IntoStatic; 1169 output.value.into_static() 1170 } 1171} 1172 1173impl jacquard_common::types::collection::Collection for Fs<'_> { 1174 const NSID: &'static str = "place.wisp.fs"; 1175 type Record = FsRecord; 1176} 1177 1178/// Marker type for deserializing records from this collection. 1179#[derive(Debug, serde::Serialize, serde::Deserialize)] 1180pub struct FsRecord; 1181impl jacquard_common::xrpc::XrpcResp for FsRecord { 1182 const NSID: &'static str = "place.wisp.fs"; 1183 const ENCODING: &'static str = "application/json"; 1184 type Output<'de> = FsGetRecordOutput<'de>; 1185 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 1186} 1187 1188impl jacquard_common::types::collection::Collection for FsRecord { 1189 const NSID: &'static str = "place.wisp.fs"; 1190 type Record = FsRecord; 1191} 1192 1193impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Fs<'a> { 1194 fn nsid() -> &'static str { 1195 "place.wisp.fs" 1196 } 1197 fn def_name() -> &'static str { 1198 "main" 1199 } 1200 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1201 lexicon_doc_place_wisp_fs() 1202 } 1203 fn validate( 1204 &self, 1205 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1206 if let Some(ref value) = self.file_count { 1207 if *value > 1000i64 { 1208 return Err(::jacquard_lexicon::validation::ConstraintError::Maximum { 1209 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1210 "file_count", 1211 ), 1212 max: 1000i64, 1213 actual: *value, 1214 }); 1215 } 1216 } 1217 if let Some(ref value) = self.file_count { 1218 if *value < 0i64 { 1219 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 1220 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1221 "file_count", 1222 ), 1223 min: 0i64, 1224 actual: *value, 1225 }); 1226 } 1227 } 1228 Ok(()) 1229 } 1230}