#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct LinkAttrs<'a> {
#[serde(borrow)]
pub href: jacquard_common::types::string::UriValue<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub rel: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub target: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub title: std::option::Option<jacquard_common::CowStr<'a>>,
}
pub mod link_attrs_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 Href;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Href = Unset;
}
pub struct SetHref<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHref<S> {}
impl<S: State> State for SetHref<S> {
type Href = Set<members::href>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct href(());
}
}
pub struct LinkAttrsBuilder<'a, S: link_attrs_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::UriValue<'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> LinkAttrs<'a> {
pub fn new() -> LinkAttrsBuilder<'a, link_attrs_state::Empty> {
LinkAttrsBuilder::new()
}
}
impl<'a> LinkAttrsBuilder<'a, link_attrs_state::Empty> {
pub fn new() -> Self {
LinkAttrsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LinkAttrsBuilder<'a, S>
where
S: link_attrs_state::State,
S::Href: link_attrs_state::IsUnset,
{
pub fn href(
mut self,
value: impl Into<jacquard_common::types::string::UriValue<'a>>,
) -> LinkAttrsBuilder<'a, link_attrs_state::SetHref<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
LinkAttrsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: link_attrs_state::State> LinkAttrsBuilder<'a, S> {
pub fn rel(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_rel(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: link_attrs_state::State> LinkAttrsBuilder<'a, S> {
pub fn target(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_target(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: link_attrs_state::State> LinkAttrsBuilder<'a, S> {
pub fn title(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_title(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> LinkAttrsBuilder<'a, S>
where
S: link_attrs_state::State,
S::Href: link_attrs_state::IsSet,
{
pub fn build(self) -> LinkAttrs<'a> {
LinkAttrs {
href: self.__unsafe_private_named.0.unwrap(),
rel: self.__unsafe_private_named.1,
target: self.__unsafe_private_named.2,
title: self.__unsafe_private_named.3,
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>,
>,
) -> LinkAttrs<'a> {
LinkAttrs {
href: self.__unsafe_private_named.0.unwrap(),
rel: self.__unsafe_private_named.1,
target: self.__unsafe_private_named.2,
title: self.__unsafe_private_named.3,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_blog_pckt_mark_link() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("blog.pckt.mark.link"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("linkAttrs"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static("Link attributes"),
),
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("href")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"href",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The URL destination of the hyperlink",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Uri,
),
default: None,
min_length: None,
max_length: Some(2000usize),
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(
"rel",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Defines the relationship between the current document and the linked resource (e.g., nofollow, noopener)",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(100usize),
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(
"target",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Specifies where to open the linked document (e.g., _blank, _self)",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(50usize),
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: Some(
::jacquard_common::CowStr::new_static(
"Additional information about the link, typically shown as a tooltip on hover",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(500usize),
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("main"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("attrs")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"attrs",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static("#linkAttrs"),
}),
);
map
},
}),
);
map
},
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for LinkAttrs<'a> {
fn nsid() -> &'static str {
"blog.pckt.mark.link"
}
fn def_name() -> &'static str {
"linkAttrs"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_blog_pckt_mark_link()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.href;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"href",
),
max: 2000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.rel {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"rel",
),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.target {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 50usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"target",
),
max: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.title {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"title",
),
max: 500usize,
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 Link<'a> {
#[serde(borrow)]
pub attrs: crate::blog_pckt::mark::link::LinkAttrs<'a>,
}
pub mod link_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 Attrs;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Attrs = Unset;
}
pub struct SetAttrs<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAttrs<S> {}
impl<S: State> State for SetAttrs<S> {
type Attrs = Set<members::attrs>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct attrs(());
}
}
pub struct LinkBuilder<'a, S: link_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<crate::blog_pckt::mark::link::LinkAttrs<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Link<'a> {
pub fn new() -> LinkBuilder<'a, link_state::Empty> {
LinkBuilder::new()
}
}
impl<'a> LinkBuilder<'a, link_state::Empty> {
pub fn new() -> Self {
LinkBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None,),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LinkBuilder<'a, S>
where
S: link_state::State,
S::Attrs: link_state::IsUnset,
{
pub fn attrs(
mut self,
value: impl Into<crate::blog_pckt::mark::link::LinkAttrs<'a>>,
) -> LinkBuilder<'a, link_state::SetAttrs<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
LinkBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LinkBuilder<'a, S>
where
S: link_state::State,
S::Attrs: link_state::IsSet,
{
pub fn build(self) -> Link<'a> {
Link {
attrs: self.__unsafe_private_named.0.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>,
>,
) -> Link<'a> {
Link {
attrs: self.__unsafe_private_named.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Link<'a> {
fn nsid() -> &'static str {
"blog.pckt.mark.link"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_blog_pckt_mark_link()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}