#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct External<'a> {
#[serde(borrow)]
pub description: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub thumb: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub thumb_hash: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(borrow)]
pub title: jacquard_common::CowStr<'a>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::UriValue<'a>,
}
pub mod external_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;
type Title;
type Description;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Title = Unset;
type Description = 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>;
type Title = S::Title;
type Description = S::Description;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Uri = S::Uri;
type Title = Set<members::title>;
type Description = S::Description;
}
pub struct SetDescription<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDescription<S> {}
impl<S: State> State for SetDescription<S> {
type Uri = S::Uri;
type Title = S::Title;
type Description = Set<members::description>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct title(());
pub struct description(());
}
}
pub struct ExternalBuilder<'a, S: external_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::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::types::string::UriValue<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> External<'a> {
pub fn new() -> ExternalBuilder<'a, external_state::Empty> {
ExternalBuilder::new()
}
}
impl<'a> ExternalBuilder<'a, external_state::Empty> {
pub fn new() -> Self {
ExternalBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ExternalBuilder<'a, S>
where
S: external_state::State,
S::Description: external_state::IsUnset,
{
pub fn description(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> ExternalBuilder<'a, external_state::SetDescription<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
ExternalBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: external_state::State> ExternalBuilder<'a, S> {
pub fn thumb(
mut self,
value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_thumb(
mut self,
value: Option<jacquard_common::types::blob::BlobRef<'a>>,
) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: external_state::State> ExternalBuilder<'a, S> {
pub fn thumb_hash(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_thumb_hash(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S> ExternalBuilder<'a, S>
where
S: external_state::State,
S::Title: external_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> ExternalBuilder<'a, external_state::SetTitle<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
ExternalBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ExternalBuilder<'a, S>
where
S: external_state::State,
S::Uri: external_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<jacquard_common::types::string::UriValue<'a>>,
) -> ExternalBuilder<'a, external_state::SetUri<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
ExternalBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ExternalBuilder<'a, S>
where
S: external_state::State,
S::Uri: external_state::IsSet,
S::Title: external_state::IsSet,
S::Description: external_state::IsSet,
{
pub fn build(self) -> External<'a> {
External {
description: self.__unsafe_private_named.0.unwrap(),
thumb: self.__unsafe_private_named.1,
thumb_hash: self.__unsafe_private_named.2,
title: self.__unsafe_private_named.3.unwrap(),
uri: self.__unsafe_private_named.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> External<'a> {
External {
description: self.__unsafe_private_named.0.unwrap(),
thumb: self.__unsafe_private_named.1,
thumb_hash: self.__unsafe_private_named.2,
title: self.__unsafe_private_named.3.unwrap(),
uri: self.__unsafe_private_named.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_art_cllctv_embed_external() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("art.cllctv.embed.external"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("uri"),
::jacquard_common::deps::smol_str::SmolStr::new_static("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("description")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"description",
),
::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.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"thumb",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
description: None,
accept: None,
max_size: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"thumbHash",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(640usize),
min_graphemes: None,
max_graphemes: Some(64usize),
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"title",
),
::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.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"uri",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Uri,
),
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::deps::smol_str::SmolStr::new_static("view"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("uri"),
::jacquard_common::deps::smol_str::SmolStr::new_static("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("description")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"description",
),
::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.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"thumb",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Uri,
),
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::deps::smol_str::SmolStr::new_static(
"title",
),
::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.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"uri",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Uri,
),
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 External<'a> {
fn nsid() -> &'static str {
"art.cllctv.embed.external"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_art_cllctv_embed_external()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
if let Some(ref value) = self.thumb {
{
let size = value.blob().size;
if size > 1000000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobTooLarge {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"thumb",
),
max: 1000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.thumb {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/*"];
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(::jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"thumb",
),
accepted: vec!["image/*".to_string()],
actual: mime.to_string(),
});
}
}
}
if let Some(ref value) = self.thumb_hash {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"thumb_hash",
),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.thumb_hash {
{
let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes(
value.as_ref(),
true,
)
.count();
if count > 64usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"thumb_hash",
),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct View<'a> {
#[serde(borrow)]
pub description: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub thumb: std::option::Option<jacquard_common::types::string::UriValue<'a>>,
#[serde(borrow)]
pub title: jacquard_common::CowStr<'a>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::UriValue<'a>,
}
pub mod view_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;
type Description;
type Title;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Description = Unset;
type Title = 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>;
type Description = S::Description;
type Title = S::Title;
}
pub struct SetDescription<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDescription<S> {}
impl<S: State> State for SetDescription<S> {
type Uri = S::Uri;
type Description = Set<members::description>;
type Title = S::Title;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Uri = S::Uri;
type Description = S::Description;
type Title = Set<members::title>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct description(());
pub struct title(());
}
}
pub struct ViewBuilder<'a, S: view_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::UriValue<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::UriValue<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> View<'a> {
pub fn new() -> ViewBuilder<'a, view_state::Empty> {
ViewBuilder::new()
}
}
impl<'a> ViewBuilder<'a, view_state::Empty> {
pub fn new() -> Self {
ViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Description: view_state::IsUnset,
{
pub fn description(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> ViewBuilder<'a, view_state::SetDescription<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
ViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: view_state::State> ViewBuilder<'a, S> {
pub fn thumb(
mut self,
value: impl Into<Option<jacquard_common::types::string::UriValue<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_thumb(
mut self,
value: Option<jacquard_common::types::string::UriValue<'a>>,
) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Title: view_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> ViewBuilder<'a, view_state::SetTitle<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
ViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Uri: view_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<jacquard_common::types::string::UriValue<'a>>,
) -> ViewBuilder<'a, view_state::SetUri<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
ViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Uri: view_state::IsSet,
S::Description: view_state::IsSet,
S::Title: view_state::IsSet,
{
pub fn build(self) -> View<'a> {
View {
description: self.__unsafe_private_named.0.unwrap(),
thumb: self.__unsafe_private_named.1,
title: self.__unsafe_private_named.2.unwrap(),
uri: self.__unsafe_private_named.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> View<'a> {
View {
description: self.__unsafe_private_named.0.unwrap(),
thumb: self.__unsafe_private_named.1,
title: self.__unsafe_private_named.2.unwrap(),
uri: self.__unsafe_private_named.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for View<'a> {
fn nsid() -> &'static str {
"art.cllctv.embed.external"
}
fn def_name() -> &'static str {
"view"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_art_cllctv_embed_external()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}