pub mod claim;
pub mod collection;
pub mod context;
pub mod funding;
pub mod helper;
pub mod workscope;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::string::UriValue;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LargeBlob<'a> {
#[serde(borrow)]
pub blob: BlobRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LargeImage<'a> {
#[serde(borrow)]
pub image: BlobRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SmallBlob<'a> {
#[serde(borrow)]
pub blob: BlobRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SmallImage<'a> {
#[serde(borrow)]
pub image: BlobRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SmallVideo<'a> {
#[serde(borrow)]
pub video: BlobRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Uri<'a> {
#[serde(borrow)]
pub uri: UriValue<'a>,
}
impl<'a> LexiconSchema for LargeBlob<'a> {
fn nsid() -> &'static str {
"org.hypercerts.defs"
}
fn def_name() -> &'static str {
"largeBlob"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.blob;
{
let size = value.blob().size;
if size > 104857600usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("blob"),
max: 104857600usize,
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(())
}
}
impl<'a> LexiconSchema for LargeImage<'a> {
fn nsid() -> &'static str {
"org.hypercerts.defs"
}
fn def_name() -> &'static str {
"largeImage"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.image;
{
let size = value.blob().size;
if size > 10485760usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("image"),
max: 10485760usize,
actual: size,
});
}
}
}
{
let value = &self.image;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &[
"image/jpeg",
"image/jpg",
"image/png",
"image/webp",
];
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("image"),
accepted: vec![
"image/jpeg".to_string(), "image/jpg".to_string(),
"image/png".to_string(), "image/webp".to_string()
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for SmallBlob<'a> {
fn nsid() -> &'static str {
"org.hypercerts.defs"
}
fn def_name() -> &'static str {
"smallBlob"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.blob;
{
let size = value.blob().size;
if size > 10485760usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("blob"),
max: 10485760usize,
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(())
}
}
impl<'a> LexiconSchema for SmallImage<'a> {
fn nsid() -> &'static str {
"org.hypercerts.defs"
}
fn def_name() -> &'static str {
"smallImage"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.image;
{
let size = value.blob().size;
if size > 5242880usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("image"),
max: 5242880usize,
actual: size,
});
}
}
}
{
let value = &self.image;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &[
"image/jpeg",
"image/jpg",
"image/png",
"image/webp",
];
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("image"),
accepted: vec![
"image/jpeg".to_string(), "image/jpg".to_string(),
"image/png".to_string(), "image/webp".to_string()
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for SmallVideo<'a> {
fn nsid() -> &'static str {
"org.hypercerts.defs"
}
fn def_name() -> &'static str {
"smallVideo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.video;
{
let size = value.blob().size;
if size > 20971520usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("video"),
max: 20971520usize,
actual: size,
});
}
}
}
{
let value = &self.video;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["video/mp4", "video/webm"];
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("video"),
accepted: vec![
"video/mp4".to_string(), "video/webm".to_string()
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Uri<'a> {
fn nsid() -> &'static str {
"org.hypercerts.defs"
}
fn def_name() -> &'static str {
"uri"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod large_blob_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 Blob;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blob = Unset;
}
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 Blob = Set<members::blob>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blob(());
}
}
pub struct LargeBlobBuilder<'a, S: large_blob_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LargeBlob<'a> {
pub fn new() -> LargeBlobBuilder<'a, large_blob_state::Empty> {
LargeBlobBuilder::new()
}
}
impl<'a> LargeBlobBuilder<'a, large_blob_state::Empty> {
pub fn new() -> Self {
LargeBlobBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> LargeBlobBuilder<'a, S>
where
S: large_blob_state::State,
S::Blob: large_blob_state::IsUnset,
{
pub fn blob(
mut self,
value: impl Into<BlobRef<'a>>,
) -> LargeBlobBuilder<'a, large_blob_state::SetBlob<S>> {
self._fields.0 = Option::Some(value.into());
LargeBlobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LargeBlobBuilder<'a, S>
where
S: large_blob_state::State,
S::Blob: large_blob_state::IsSet,
{
pub fn build(self) -> LargeBlob<'a> {
LargeBlob {
blob: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> LargeBlob<'a> {
LargeBlob {
blob: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_hypercerts_defs() -> 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("org.hypercerts.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("largeBlob"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Object containing a blob to external data"),
),
required: Some(vec![SmolStr::new_static("blob")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blob"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("largeImage"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Object containing a large image"),
),
required: Some(vec![SmolStr::new_static("image")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("image"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("smallBlob"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Object containing a blob to external data"),
),
required: Some(vec![SmolStr::new_static("blob")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blob"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("smallImage"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Object containing a small image"),
),
required: Some(vec![SmolStr::new_static("image")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("image"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("smallVideo"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Object containing a small video"),
),
required: Some(vec![SmolStr::new_static("video")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("video"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Object containing a URI to external data"),
),
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URI to external data"),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod large_image_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 Image;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Image = Unset;
}
pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetImage<S> {}
impl<S: State> State for SetImage<S> {
type Image = Set<members::image>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct image(());
}
}
pub struct LargeImageBuilder<'a, S: large_image_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LargeImage<'a> {
pub fn new() -> LargeImageBuilder<'a, large_image_state::Empty> {
LargeImageBuilder::new()
}
}
impl<'a> LargeImageBuilder<'a, large_image_state::Empty> {
pub fn new() -> Self {
LargeImageBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> LargeImageBuilder<'a, S>
where
S: large_image_state::State,
S::Image: large_image_state::IsUnset,
{
pub fn image(
mut self,
value: impl Into<BlobRef<'a>>,
) -> LargeImageBuilder<'a, large_image_state::SetImage<S>> {
self._fields.0 = Option::Some(value.into());
LargeImageBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LargeImageBuilder<'a, S>
where
S: large_image_state::State,
S::Image: large_image_state::IsSet,
{
pub fn build(self) -> LargeImage<'a> {
LargeImage {
image: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> LargeImage<'a> {
LargeImage {
image: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod small_blob_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 Blob;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blob = Unset;
}
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 Blob = Set<members::blob>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blob(());
}
}
pub struct SmallBlobBuilder<'a, S: small_blob_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> SmallBlob<'a> {
pub fn new() -> SmallBlobBuilder<'a, small_blob_state::Empty> {
SmallBlobBuilder::new()
}
}
impl<'a> SmallBlobBuilder<'a, small_blob_state::Empty> {
pub fn new() -> Self {
SmallBlobBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SmallBlobBuilder<'a, S>
where
S: small_blob_state::State,
S::Blob: small_blob_state::IsUnset,
{
pub fn blob(
mut self,
value: impl Into<BlobRef<'a>>,
) -> SmallBlobBuilder<'a, small_blob_state::SetBlob<S>> {
self._fields.0 = Option::Some(value.into());
SmallBlobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SmallBlobBuilder<'a, S>
where
S: small_blob_state::State,
S::Blob: small_blob_state::IsSet,
{
pub fn build(self) -> SmallBlob<'a> {
SmallBlob {
blob: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> SmallBlob<'a> {
SmallBlob {
blob: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod small_image_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 Image;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Image = Unset;
}
pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetImage<S> {}
impl<S: State> State for SetImage<S> {
type Image = Set<members::image>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct image(());
}
}
pub struct SmallImageBuilder<'a, S: small_image_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> SmallImage<'a> {
pub fn new() -> SmallImageBuilder<'a, small_image_state::Empty> {
SmallImageBuilder::new()
}
}
impl<'a> SmallImageBuilder<'a, small_image_state::Empty> {
pub fn new() -> Self {
SmallImageBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SmallImageBuilder<'a, S>
where
S: small_image_state::State,
S::Image: small_image_state::IsUnset,
{
pub fn image(
mut self,
value: impl Into<BlobRef<'a>>,
) -> SmallImageBuilder<'a, small_image_state::SetImage<S>> {
self._fields.0 = Option::Some(value.into());
SmallImageBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SmallImageBuilder<'a, S>
where
S: small_image_state::State,
S::Image: small_image_state::IsSet,
{
pub fn build(self) -> SmallImage<'a> {
SmallImage {
image: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> SmallImage<'a> {
SmallImage {
image: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod small_video_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 Video;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Video = Unset;
}
pub struct SetVideo<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetVideo<S> {}
impl<S: State> State for SetVideo<S> {
type Video = Set<members::video>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct video(());
}
}
pub struct SmallVideoBuilder<'a, S: small_video_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> SmallVideo<'a> {
pub fn new() -> SmallVideoBuilder<'a, small_video_state::Empty> {
SmallVideoBuilder::new()
}
}
impl<'a> SmallVideoBuilder<'a, small_video_state::Empty> {
pub fn new() -> Self {
SmallVideoBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SmallVideoBuilder<'a, S>
where
S: small_video_state::State,
S::Video: small_video_state::IsUnset,
{
pub fn video(
mut self,
value: impl Into<BlobRef<'a>>,
) -> SmallVideoBuilder<'a, small_video_state::SetVideo<S>> {
self._fields.0 = Option::Some(value.into());
SmallVideoBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SmallVideoBuilder<'a, S>
where
S: small_video_state::State,
S::Video: small_video_state::IsSet,
{
pub fn build(self) -> SmallVideo<'a> {
SmallVideo {
video: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> SmallVideo<'a> {
SmallVideo {
video: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod uri_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct UriBuilder<'a, S: uri_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<UriValue<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Uri<'a> {
pub fn new() -> UriBuilder<'a, uri_state::Empty> {
UriBuilder::new()
}
}
impl<'a> UriBuilder<'a, uri_state::Empty> {
pub fn new() -> Self {
UriBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> UriBuilder<'a, S>
where
S: uri_state::State,
S::Uri: uri_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<'a>>,
) -> UriBuilder<'a, uri_state::SetUri<S>> {
self._fields.0 = Option::Some(value.into());
UriBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UriBuilder<'a, S>
where
S: uri_state::State,
S::Uri: uri_state::IsSet,
{
pub fn build(self) -> Uri<'a> {
Uri {
uri: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Uri<'a> {
Uri {
uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}