Something went wrong. Try again.
Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.
Something went wrong. Try again.
44 kB · 1230 lines
Rust
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230// @generated by jacquard-lexicon. DO NOT EDIT.//// Lexicon: place.wisp.fs//// This file was automatically generated from Lexicon schemas.// Any manual changes will be overwritten on the next regeneration.
#[jacquard_derive::lexicon]#[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Directory<'a> { #[serde(borrow)] pub entries: Vec<crate::place_wisp::fs::Entry<'a>>, #[serde(borrow)] pub r#type: jacquard_common::CowStr<'a>,}
pub mod directory_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Type; type Entries; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Type = Unset; type Entries = Unset; } ///State transition - sets the `type` field to Set pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetType<S> {} impl<S: State> State for SetType<S> { type Type = Set<members::r#type>; type Entries = S::Entries; } ///State transition - sets the `entries` field to Set pub struct SetEntries<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetEntries<S> {} impl<S: State> State for SetEntries<S> { type Type = S::Type; type Entries = Set<members::entries>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `type` field pub struct r#type(()); ///Marker type for the `entries` field pub struct entries(()); }}
/// Builder for constructing an instance of this typepub struct DirectoryBuilder<'a, S: directory_state::State> { _phantom_state: ::core::marker::PhantomData<fn() -> S>, __unsafe_private_named: ( ::core::option::Option<Vec<crate::place_wisp::fs::Entry<'a>>>, ::core::option::Option<jacquard_common::CowStr<'a>>, ), _phantom: ::core::marker::PhantomData<&'a ()>,}
impl<'a> Directory<'a> { /// Create a new builder for this type pub fn new() -> DirectoryBuilder<'a, directory_state::Empty> { DirectoryBuilder::new() }}
impl<'a> DirectoryBuilder<'a, directory_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { DirectoryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> DirectoryBuilder<'a, S>where S: directory_state::State, S::Entries: directory_state::IsUnset,{ /// Set the `entries` field (required) pub fn entries( mut self, value: impl Into<Vec<crate::place_wisp::fs::Entry<'a>>>, ) -> DirectoryBuilder<'a, directory_state::SetEntries<S>> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); DirectoryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> DirectoryBuilder<'a, S>where S: directory_state::State, S::Type: directory_state::IsUnset,{ /// Set the `type` field (required) pub fn r#type( mut self, value: impl Into<jacquard_common::CowStr<'a>>, ) -> DirectoryBuilder<'a, directory_state::SetType<S>> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); DirectoryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> DirectoryBuilder<'a, S>where S: directory_state::State, S::Type: directory_state::IsSet, S::Entries: directory_state::IsSet,{ /// Build the final struct pub fn build(self) -> Directory<'a> { Directory { entries: self.__unsafe_private_named.0.unwrap(), r#type: self.__unsafe_private_named.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Directory<'a> { Directory { entries: self.__unsafe_private_named.0.unwrap(), r#type: self.__unsafe_private_named.1.unwrap(), extra_data: Some(extra_data), } }}
fn lexicon_doc_place_wisp_fs() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("place.wisp.fs"), revision: None, description: None, defs: { let mut map = ::std::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("directory"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("type"), ::jacquard_common::smol_str::SmolStr::new_static("entries") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::std::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("entries"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#entry"), }), min_length: None, max_length: Some(500usize), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("type"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("entry"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_common::smol_str::SmolStr::new_static("node") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::std::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(255usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("node"), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("#file"), ::jacquard_common::CowStr::new_static("#directory") ], closed: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("file"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("type"), ::jacquard_common::smol_str::SmolStr::new_static("blob") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::std::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("base64"), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("blob"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("encoding"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Content encoding (e.g., gzip for compressed files)", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("mimeType"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Original MIME type before compression", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("type"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { description: Some( ::jacquard_common::CowStr::new_static( "Virtual filesystem manifest for a Wisp site", ), ), key: None, record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("site"), ::jacquard_common::smol_str::SmolStr::new_static("root"), ::jacquard_common::smol_str::SmolStr::new_static("createdAt") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::std::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "createdAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "fileCount", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: Some(0i64), maximum: Some(1000i64), r#enum: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("root"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#directory"), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("site"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), }), ); map }, }}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Directory<'a> { fn nsid() -> &'static str { "place.wisp.fs" } fn def_name() -> &'static str { "directory" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_place_wisp_fs() } fn validate( &self, ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { { let value = &self.entries; #[allow(unused_comparisons)] if value.len() > 500usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "entries", ), max: 500usize, actual: value.len(), }); } } Ok(()) }}
#[jacquard_derive::lexicon]#[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Entry<'a> { #[serde(borrow)] pub name: jacquard_common::CowStr<'a>, #[serde(borrow)] pub node: EntryNode<'a>,}
pub mod entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Name; type Node; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Name = Unset; type Node = Unset; } ///State transition - sets the `name` field to Set pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetName<S> {} impl<S: State> State for SetName<S> { type Name = Set<members::name>; type Node = S::Node; } ///State transition - sets the `node` field to Set pub struct SetNode<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetNode<S> {} impl<S: State> State for SetNode<S> { type Name = S::Name; type Node = Set<members::node>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `name` field pub struct name(()); ///Marker type for the `node` field pub struct node(()); }}
/// Builder for constructing an instance of this typepub struct EntryBuilder<'a, S: entry_state::State> { _phantom_state: ::core::marker::PhantomData<fn() -> S>, __unsafe_private_named: ( ::core::option::Option<jacquard_common::CowStr<'a>>, ::core::option::Option<EntryNode<'a>>, ), _phantom: ::core::marker::PhantomData<&'a ()>,}
impl<'a> Entry<'a> { /// Create a new builder for this type pub fn new() -> EntryBuilder<'a, entry_state::Empty> { EntryBuilder::new() }}
impl<'a> EntryBuilder<'a, entry_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> EntryBuilder<'a, S>where S: entry_state::State, S::Name: entry_state::IsUnset,{ /// Set the `name` field (required) pub fn name( mut self, value: impl Into<jacquard_common::CowStr<'a>>, ) -> EntryBuilder<'a, entry_state::SetName<S>> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> EntryBuilder<'a, S>where S: entry_state::State, S::Node: entry_state::IsUnset,{ /// Set the `node` field (required) pub fn node( mut self, value: impl Into<EntryNode<'a>>, ) -> EntryBuilder<'a, entry_state::SetNode<S>> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> EntryBuilder<'a, S>where S: entry_state::State, S::Name: entry_state::IsSet, S::Node: entry_state::IsSet,{ /// Build the final struct pub fn build(self) -> Entry<'a> { Entry { name: self.__unsafe_private_named.0.unwrap(), node: self.__unsafe_private_named.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Entry<'a> { Entry { name: self.__unsafe_private_named.0.unwrap(), node: self.__unsafe_private_named.1.unwrap(), extra_data: Some(extra_data), } }}
#[jacquard_derive::open_union]#[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic)]#[serde(tag = "$type")]#[serde(bound(deserialize = "'de: 'a"))]pub enum EntryNode<'a> { #[serde(rename = "place.wisp.fs#file")] File(Box<crate::place_wisp::fs::File<'a>>), #[serde(rename = "place.wisp.fs#directory")] Directory(Box<crate::place_wisp::fs::Directory<'a>>),}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Entry<'a> { fn nsid() -> &'static str { "place.wisp.fs" } fn def_name() -> &'static str { "entry" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_place_wisp_fs() } fn validate( &self, ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { { let value = &self.name; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 255usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), max: 255usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
#[jacquard_derive::lexicon]#[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic)]#[serde(rename_all = "camelCase")]pub struct File<'a> { /// True if blob content is base64-encoded (used to bypass PDS content sniffing) #[serde(skip_serializing_if = "std::option::Option::is_none")] pub base64: Option<bool>, /// Content blob ref #[serde(borrow)] pub blob: jacquard_common::types::blob::BlobRef<'a>, /// Content encoding (e.g., gzip for compressed files) #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub encoding: Option<jacquard_common::CowStr<'a>>, /// Original MIME type before compression #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub mime_type: Option<jacquard_common::CowStr<'a>>, #[serde(borrow)] pub r#type: jacquard_common::CowStr<'a>,}
pub mod file_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Type; type Blob; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Type = Unset; type Blob = Unset; } ///State transition - sets the `type` field to Set pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetType<S> {} impl<S: State> State for SetType<S> { type Type = Set<members::r#type>; type Blob = S::Blob; } ///State transition - sets the `blob` field to Set pub struct SetBlob<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetBlob<S> {} impl<S: State> State for SetBlob<S> { type Type = S::Type; type Blob = Set<members::blob>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `type` field pub struct r#type(()); ///Marker type for the `blob` field pub struct blob(()); }}
/// Builder for constructing an instance of this typepub struct FileBuilder<'a, S: file_state::State> { _phantom_state: ::core::marker::PhantomData<fn() -> S>, __unsafe_private_named: ( ::core::option::Option<bool>, ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>, ::core::option::Option<jacquard_common::CowStr<'a>>, ::core::option::Option<jacquard_common::CowStr<'a>>, ::core::option::Option<jacquard_common::CowStr<'a>>, ), _phantom: ::core::marker::PhantomData<&'a ()>,}
impl<'a> File<'a> { /// Create a new builder for this type pub fn new() -> FileBuilder<'a, file_state::Empty> { FileBuilder::new() }}
impl<'a> FileBuilder<'a, file_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { FileBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None), _phantom: ::core::marker::PhantomData, } }}
impl<'a, S: file_state::State> FileBuilder<'a, S> { /// Set the `base64` field (optional) pub fn base64(mut self, value: impl Into<Option<bool>>) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `base64` field to an Option value (optional) pub fn maybe_base64(mut self, value: Option<bool>) -> Self { self.__unsafe_private_named.0 = value; self }}
impl<'a, S> FileBuilder<'a, S>where S: file_state::State, S::Blob: file_state::IsUnset,{ /// Set the `blob` field (required) pub fn blob( mut self, value: impl Into<jacquard_common::types::blob::BlobRef<'a>>, ) -> FileBuilder<'a, file_state::SetBlob<S>> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); FileBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S: file_state::State> FileBuilder<'a, S> { /// Set the `encoding` field (optional) pub fn encoding( mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `encoding` field to an Option value (optional) pub fn maybe_encoding(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { self.__unsafe_private_named.2 = value; self }}
impl<'a, S: file_state::State> FileBuilder<'a, S> { /// Set the `mimeType` field (optional) pub fn mime_type( mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `mimeType` field to an Option value (optional) pub fn maybe_mime_type( mut self, value: Option<jacquard_common::CowStr<'a>>, ) -> Self { self.__unsafe_private_named.3 = value; self }}
impl<'a, S> FileBuilder<'a, S>where S: file_state::State, S::Type: file_state::IsUnset,{ /// Set the `type` field (required) pub fn r#type( mut self, value: impl Into<jacquard_common::CowStr<'a>>, ) -> FileBuilder<'a, file_state::SetType<S>> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); FileBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> FileBuilder<'a, S>where S: file_state::State, S::Type: file_state::IsSet, S::Blob: file_state::IsSet,{ /// Build the final struct pub fn build(self) -> File<'a> { File { base64: self.__unsafe_private_named.0, blob: self.__unsafe_private_named.1.unwrap(), encoding: self.__unsafe_private_named.2, mime_type: self.__unsafe_private_named.3, r#type: self.__unsafe_private_named.4.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> File<'a> { File { base64: self.__unsafe_private_named.0, blob: self.__unsafe_private_named.1.unwrap(), encoding: self.__unsafe_private_named.2, mime_type: self.__unsafe_private_named.3, r#type: self.__unsafe_private_named.4.unwrap(), extra_data: Some(extra_data), } }}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for File<'a> { fn nsid() -> &'static str { "place.wisp.fs" } fn def_name() -> &'static str { "file" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_place_wisp_fs() } fn validate( &self, ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) }}
/// Virtual filesystem manifest for a Wisp site#[jacquard_derive::lexicon]#[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Fs<'a> { pub created_at: jacquard_common::types::string::Datetime, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub file_count: Option<i64>, #[serde(borrow)] pub root: crate::place_wisp::fs::Directory<'a>, #[serde(borrow)] pub site: jacquard_common::CowStr<'a>,}
pub mod fs_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Site; type Root; type CreatedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Site = Unset; type Root = Unset; type CreatedAt = Unset; } ///State transition - sets the `site` field to Set pub struct SetSite<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetSite<S> {} impl<S: State> State for SetSite<S> { type Site = Set<members::site>; type Root = S::Root; type CreatedAt = S::CreatedAt; } ///State transition - sets the `root` field to Set pub struct SetRoot<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetRoot<S> {} impl<S: State> State for SetRoot<S> { type Site = S::Site; type Root = Set<members::root>; type CreatedAt = S::CreatedAt; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetCreatedAt<S> {} impl<S: State> State for SetCreatedAt<S> { type Site = S::Site; type Root = S::Root; type CreatedAt = Set<members::created_at>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `site` field pub struct site(()); ///Marker type for the `root` field pub struct root(()); ///Marker type for the `created_at` field pub struct created_at(()); }}
/// Builder for constructing an instance of this typepub struct FsBuilder<'a, S: fs_state::State> { _phantom_state: ::core::marker::PhantomData<fn() -> S>, __unsafe_private_named: ( ::core::option::Option<jacquard_common::types::string::Datetime>, ::core::option::Option<i64>, ::core::option::Option<crate::place_wisp::fs::Directory<'a>>, ::core::option::Option<jacquard_common::CowStr<'a>>, ), _phantom: ::core::marker::PhantomData<&'a ()>,}
impl<'a> Fs<'a> { /// Create a new builder for this type pub fn new() -> FsBuilder<'a, fs_state::Empty> { FsBuilder::new() }}
impl<'a> FsBuilder<'a, fs_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { FsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None), _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> FsBuilder<'a, S>where S: fs_state::State, S::CreatedAt: fs_state::IsUnset,{ /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into<jacquard_common::types::string::Datetime>, ) -> FsBuilder<'a, fs_state::SetCreatedAt<S>> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); FsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S: fs_state::State> FsBuilder<'a, S> { /// Set the `fileCount` field (optional) pub fn file_count(mut self, value: impl Into<Option<i64>>) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `fileCount` field to an Option value (optional) pub fn maybe_file_count(mut self, value: Option<i64>) -> Self { self.__unsafe_private_named.1 = value; self }}
impl<'a, S> FsBuilder<'a, S>where S: fs_state::State, S::Root: fs_state::IsUnset,{ /// Set the `root` field (required) pub fn root( mut self, value: impl Into<crate::place_wisp::fs::Directory<'a>>, ) -> FsBuilder<'a, fs_state::SetRoot<S>> { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); FsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> FsBuilder<'a, S>where S: fs_state::State, S::Site: fs_state::IsUnset,{ /// Set the `site` field (required) pub fn site( mut self, value: impl Into<jacquard_common::CowStr<'a>>, ) -> FsBuilder<'a, fs_state::SetSite<S>> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); FsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } }}
impl<'a, S> FsBuilder<'a, S>where S: fs_state::State, S::Site: fs_state::IsSet, S::Root: fs_state::IsSet, S::CreatedAt: fs_state::IsSet,{ /// Build the final struct pub fn build(self) -> Fs<'a> { Fs { created_at: self.__unsafe_private_named.0.unwrap(), file_count: self.__unsafe_private_named.1, root: self.__unsafe_private_named.2.unwrap(), site: self.__unsafe_private_named.3.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Fs<'a> { Fs { created_at: self.__unsafe_private_named.0.unwrap(), file_count: self.__unsafe_private_named.1, root: self.__unsafe_private_named.2.unwrap(), site: self.__unsafe_private_named.3.unwrap(), extra_data: Some(extra_data), } }}
impl<'a> Fs<'a> { pub fn uri( uri: impl Into<jacquard_common::CowStr<'a>>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, FsRecord>, jacquard_common::types::uri::UriError, > { jacquard_common::types::uri::RecordUri::try_from_uri( jacquard_common::types::string::AtUri::new_cow(uri.into())?, ) }}
/// Typed wrapper for GetRecord response with this collection's record type.#[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic)]#[serde(rename_all = "camelCase")]pub struct FsGetRecordOutput<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>, #[serde(borrow)] pub uri: jacquard_common::types::string::AtUri<'a>, #[serde(borrow)] pub value: Fs<'a>,}
impl From<FsGetRecordOutput<'_>> for Fs<'_> { fn from(output: FsGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() }}
impl jacquard_common::types::collection::Collection for Fs<'_> { const NSID: &'static str = "place.wisp.fs"; type Record = FsRecord;}
/// Marker type for deserializing records from this collection.#[derive(Debug, serde::Serialize, serde::Deserialize)]pub struct FsRecord;impl jacquard_common::xrpc::XrpcResp for FsRecord { const NSID: &'static str = "place.wisp.fs"; const ENCODING: &'static str = "application/json"; type Output<'de> = FsGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>;}
impl jacquard_common::types::collection::Collection for FsRecord { const NSID: &'static str = "place.wisp.fs"; type Record = FsRecord;}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Fs<'a> { fn nsid() -> &'static str { "place.wisp.fs" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_place_wisp_fs() } fn validate( &self, ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.file_count { if *value > 1000i64 { return Err(::jacquard_lexicon::validation::ConstraintError::Maximum { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "file_count", ), max: 1000i64, actual: *value, }); } } if let Some(ref value) = self.file_count { if *value < 0i64 { return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "file_count", ), min: 0i64, actual: *value, }); } } Ok(()) }}