#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::place_wisp::fs;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Directory<S: BosStr = DefaultStr> {
pub entries: Vec<fs::Entry<S>>,
pub r#type: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Entry<S: BosStr = DefaultStr> {
pub name: S,
pub node: EntryNode<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum EntryNode<S: BosStr = DefaultStr> {
#[serde(rename = "place.wisp.fs#file")]
File(Box<fs::File<S>>),
#[serde(rename = "place.wisp.fs#directory")]
Directory(Box<fs::Directory<S>>),
#[serde(rename = "place.wisp.fs#subfs")]
Subfs(Box<fs::Subfs<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct File<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub base64: Option<bool>,
pub blob: BlobRef<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub encoding: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mime_type: Option<S>,
pub r#type: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "place.wisp.fs",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Fs<S: BosStr = DefaultStr> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub file_count: Option<i64>,
pub root: fs::Directory<S>,
pub site: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct FsGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Fs<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Subfs<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub flat: Option<bool>,
pub subject: AtUri<S>,
pub r#type: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Fs<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, FsRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Directory<S> {
fn nsid() -> &'static str {
"place.wisp.fs"
}
fn def_name() -> &'static str {
"directory"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_wisp_fs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.entries;
#[allow(unused_comparisons)]
if value.len() > 500usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("entries"),
max: 500usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Entry<S> {
fn nsid() -> &'static str {
"place.wisp.fs"
}
fn def_name() -> &'static str {
"entry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_wisp_fs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 255usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 255usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for File<S> {
fn nsid() -> &'static str {
"place.wisp.fs"
}
fn def_name() -> &'static str {
"file"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_wisp_fs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.blob;
{
let size = value.blob().size;
if size > 1000000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("blob"),
max: 1000000000usize,
actual: size,
});
}
}
}
{
let value = &self.blob;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["*/*"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("blob"),
accepted: vec!["*/*".to_string()],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct FsRecord;
impl XrpcResp for FsRecord {
const NSID: &'static str = "place.wisp.fs";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = FsGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<FsGetRecordOutput<S>> for Fs<S> {
fn from(output: FsGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Fs<S> {
const NSID: &'static str = "place.wisp.fs";
type Record = FsRecord;
}
impl Collection for FsRecord {
const NSID: &'static str = "place.wisp.fs";
type Record = FsRecord;
}
impl<S: BosStr> LexiconSchema for Fs<S> {
fn nsid() -> &'static str {
"place.wisp.fs"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_wisp_fs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.file_count {
if *value > 1000i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("file_count"),
max: 1000i64,
actual: *value,
});
}
}
if let Some(ref value) = self.file_count {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("file_count"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Subfs<S> {
fn nsid() -> &'static str {
"place.wisp.fs"
}
fn def_name() -> &'static str {
"subfs"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_wisp_fs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod directory_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Type;
type Entries;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Type = Unset;
type Entries = Unset;
}
pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetType<St> {}
impl<St: State> State for SetType<St> {
type Type = Set<members::r#type>;
type Entries = St::Entries;
}
pub struct SetEntries<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEntries<St> {}
impl<St: State> State for SetEntries<St> {
type Type = St::Type;
type Entries = Set<members::entries>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#type(());
pub struct entries(());
}
}
pub struct DirectoryBuilder<S: BosStr, St: directory_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<fs::Entry<S>>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Directory<S> {
pub fn new() -> DirectoryBuilder<S, directory_state::Empty> {
DirectoryBuilder::new()
}
}
impl<S: BosStr> DirectoryBuilder<S, directory_state::Empty> {
pub fn new() -> Self {
DirectoryBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DirectoryBuilder<S, St>
where
St: directory_state::State,
St::Entries: directory_state::IsUnset,
{
pub fn entries(
mut self,
value: impl Into<Vec<fs::Entry<S>>>,
) -> DirectoryBuilder<S, directory_state::SetEntries<St>> {
self._fields.0 = Option::Some(value.into());
DirectoryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DirectoryBuilder<S, St>
where
St: directory_state::State,
St::Type: directory_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<S>,
) -> DirectoryBuilder<S, directory_state::SetType<St>> {
self._fields.1 = Option::Some(value.into());
DirectoryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DirectoryBuilder<S, St>
where
St: directory_state::State,
St::Type: directory_state::IsSet,
St::Entries: directory_state::IsSet,
{
pub fn build(self) -> Directory<S> {
Directory {
entries: self._fields.0.unwrap(),
r#type: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> Directory<S> {
Directory {
entries: self._fields.0.unwrap(),
r#type: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_place_wisp_fs() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("place.wisp.fs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("directory"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("type"), SmolStr::new_static("entries")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("entries"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#entry"),
..Default::default()
}),
max_length: Some(500usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("entry"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("name"), SmolStr::new_static("node")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
max_length: Some(255usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("node"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#file"),
CowStr::new_static("#directory"),
CowStr::new_static("#subfs")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("file"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("type"), SmolStr::new_static("blob")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("base64"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("blob"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("encoding"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Content encoding (e.g., gzip for compressed files)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mimeType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Original MIME type before compression"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("Virtual filesystem manifest for a Wisp site"),
),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("site"), SmolStr::new_static("root"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("fileCount"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(1000i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("root"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#directory"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("site"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subfs"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("type"), SmolStr::new_static("subject")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("flat"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI pointing to a place.wisp.subfs record containing this subtree.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type Node;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Node = Unset;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Name = Set<members::name>;
type Node = St::Node;
}
pub struct SetNode<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNode<St> {}
impl<St: State> State for SetNode<St> {
type Name = St::Name;
type Node = Set<members::node>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct node(());
}
}
pub struct EntryBuilder<S: BosStr, St: entry_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<EntryNode<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Entry<S> {
pub fn new() -> EntryBuilder<S, entry_state::Empty> {
EntryBuilder::new()
}
}
impl<S: BosStr> EntryBuilder<S, entry_state::Empty> {
pub fn new() -> Self {
EntryBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EntryBuilder<S, St>
where
St: entry_state::State,
St::Name: entry_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> EntryBuilder<S, entry_state::SetName<St>> {
self._fields.0 = Option::Some(value.into());
EntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EntryBuilder<S, St>
where
St: entry_state::State,
St::Node: entry_state::IsUnset,
{
pub fn node(
mut self,
value: impl Into<EntryNode<S>>,
) -> EntryBuilder<S, entry_state::SetNode<St>> {
self._fields.1 = Option::Some(value.into());
EntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EntryBuilder<S, St>
where
St: entry_state::State,
St::Name: entry_state::IsSet,
St::Node: entry_state::IsSet,
{
pub fn build(self) -> Entry<S> {
Entry {
name: self._fields.0.unwrap(),
node: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Entry<S> {
Entry {
name: self._fields.0.unwrap(),
node: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod file_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Type;
type Blob;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Type = Unset;
type Blob = Unset;
}
pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetType<St> {}
impl<St: State> State for SetType<St> {
type Type = Set<members::r#type>;
type Blob = St::Blob;
}
pub struct SetBlob<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlob<St> {}
impl<St: State> State for SetBlob<St> {
type Type = St::Type;
type Blob = Set<members::blob>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#type(());
pub struct blob(());
}
}
pub struct FileBuilder<S: BosStr, St: file_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<bool>, Option<BlobRef<S>>, Option<S>, Option<S>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> File<S> {
pub fn new() -> FileBuilder<S, file_state::Empty> {
FileBuilder::new()
}
}
impl<S: BosStr> FileBuilder<S, file_state::Empty> {
pub fn new() -> Self {
FileBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: file_state::State> FileBuilder<S, St> {
pub fn base64(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_base64(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> FileBuilder<S, St>
where
St: file_state::State,
St::Blob: file_state::IsUnset,
{
pub fn blob(
mut self,
value: impl Into<BlobRef<S>>,
) -> FileBuilder<S, file_state::SetBlob<St>> {
self._fields.1 = Option::Some(value.into());
FileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: file_state::State> FileBuilder<S, St> {
pub fn encoding(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_encoding(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: file_state::State> FileBuilder<S, St> {
pub fn mime_type(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_mime_type(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> FileBuilder<S, St>
where
St: file_state::State,
St::Type: file_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<S>,
) -> FileBuilder<S, file_state::SetType<St>> {
self._fields.4 = Option::Some(value.into());
FileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FileBuilder<S, St>
where
St: file_state::State,
St::Type: file_state::IsSet,
St::Blob: file_state::IsSet,
{
pub fn build(self) -> File<S> {
File {
base64: self._fields.0,
blob: self._fields.1.unwrap(),
encoding: self._fields.2,
mime_type: self._fields.3,
r#type: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> File<S> {
File {
base64: self._fields.0,
blob: self._fields.1.unwrap(),
encoding: self._fields.2,
mime_type: self._fields.3,
r#type: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod fs_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Site;
type CreatedAt;
type Root;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Site = Unset;
type CreatedAt = Unset;
type Root = Unset;
}
pub struct SetSite<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSite<St> {}
impl<St: State> State for SetSite<St> {
type Site = Set<members::site>;
type CreatedAt = St::CreatedAt;
type Root = St::Root;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Site = St::Site;
type CreatedAt = Set<members::created_at>;
type Root = St::Root;
}
pub struct SetRoot<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRoot<St> {}
impl<St: State> State for SetRoot<St> {
type Site = St::Site;
type CreatedAt = St::CreatedAt;
type Root = Set<members::root>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct site(());
pub struct created_at(());
pub struct root(());
}
}
pub struct FsBuilder<S: BosStr, St: fs_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>, Option<i64>, Option<fs::Directory<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Fs<S> {
pub fn new() -> FsBuilder<S, fs_state::Empty> {
FsBuilder::new()
}
}
impl<S: BosStr> FsBuilder<S, fs_state::Empty> {
pub fn new() -> Self {
FsBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FsBuilder<S, St>
where
St: fs_state::State,
St::CreatedAt: fs_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> FsBuilder<S, fs_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
FsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: fs_state::State> FsBuilder<S, St> {
pub fn file_count(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_file_count(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> FsBuilder<S, St>
where
St: fs_state::State,
St::Root: fs_state::IsUnset,
{
pub fn root(
mut self,
value: impl Into<fs::Directory<S>>,
) -> FsBuilder<S, fs_state::SetRoot<St>> {
self._fields.2 = Option::Some(value.into());
FsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FsBuilder<S, St>
where
St: fs_state::State,
St::Site: fs_state::IsUnset,
{
pub fn site(mut self, value: impl Into<S>) -> FsBuilder<S, fs_state::SetSite<St>> {
self._fields.3 = Option::Some(value.into());
FsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FsBuilder<S, St>
where
St: fs_state::State,
St::Site: fs_state::IsSet,
St::CreatedAt: fs_state::IsSet,
St::Root: fs_state::IsSet,
{
pub fn build(self) -> Fs<S> {
Fs {
created_at: self._fields.0.unwrap(),
file_count: self._fields.1,
root: self._fields.2.unwrap(),
site: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Fs<S> {
Fs {
created_at: self._fields.0.unwrap(),
file_count: self._fields.1,
root: self._fields.2.unwrap(),
site: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod subfs_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Type;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Type = Unset;
type Subject = Unset;
}
pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetType<St> {}
impl<St: State> State for SetType<St> {
type Type = Set<members::r#type>;
type Subject = St::Subject;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Type = St::Type;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#type(());
pub struct subject(());
}
}
pub struct SubfsBuilder<S: BosStr, St: subfs_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<bool>, Option<AtUri<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Subfs<S> {
pub fn new() -> SubfsBuilder<S, subfs_state::Empty> {
SubfsBuilder::new()
}
}
impl<S: BosStr> SubfsBuilder<S, subfs_state::Empty> {
pub fn new() -> Self {
SubfsBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: subfs_state::State> SubfsBuilder<S, St> {
pub fn flat(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_flat(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> SubfsBuilder<S, St>
where
St: subfs_state::State,
St::Subject: subfs_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<AtUri<S>>,
) -> SubfsBuilder<S, subfs_state::SetSubject<St>> {
self._fields.1 = Option::Some(value.into());
SubfsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubfsBuilder<S, St>
where
St: subfs_state::State,
St::Type: subfs_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<S>,
) -> SubfsBuilder<S, subfs_state::SetType<St>> {
self._fields.2 = Option::Some(value.into());
SubfsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubfsBuilder<S, St>
where
St: subfs_state::State,
St::Type: subfs_state::IsSet,
St::Subject: subfs_state::IsSet,
{
pub fn build(self) -> Subfs<S> {
Subfs {
flat: self._fields.0,
subject: self._fields.1.unwrap(),
r#type: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Subfs<S> {
Subfs {
flat: self._fields.0,
subject: self._fields.1.unwrap(),
r#type: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}