#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, UriValue};
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::pub_leaflet::richtext::facet;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AtMention<'a> {
#[serde(borrow)]
pub at_uri: UriValue<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Bold<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ByteSlice<'a> {
pub byte_end: i64,
pub byte_start: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Code<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct DidMention<'a> {
#[serde(borrow)]
pub did: Did<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Footnote<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub content_facets: Option<Vec<facet::Facet<'a>>>,
#[serde(borrow)]
pub content_plaintext: CowStr<'a>,
#[serde(borrow)]
pub footnote_id: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Highlight<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Id<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub id: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Italic<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Link<'a> {
#[serde(borrow)]
pub uri: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Facet<'a> {
#[serde(borrow)]
pub features: Vec<FacetFeaturesItem<'a>>,
#[serde(borrow)]
pub index: facet::ByteSlice<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum FacetFeaturesItem<'a> {
#[serde(rename = "pub.leaflet.richtext.facet#link")]
Link(Box<facet::Link<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#didMention")]
DidMention(Box<facet::DidMention<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#atMention")]
AtMention(Box<facet::AtMention<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#code")]
Code(Box<facet::Code<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#highlight")]
Highlight(Box<facet::Highlight<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#underline")]
Underline(Box<facet::Underline<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#strikethrough")]
Strikethrough(Box<facet::Strikethrough<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#id")]
Id(Box<facet::Id<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#bold")]
Bold(Box<facet::Bold<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#italic")]
Italic(Box<facet::Italic<'a>>),
#[serde(rename = "pub.leaflet.richtext.facet#footnote")]
Footnote(Box<facet::Footnote<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Strikethrough<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Underline<'a> {}
impl<'a> LexiconSchema for AtMention<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"atMention"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Bold<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"bold"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for ByteSlice<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"byteSlice"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.byte_end;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("byte_end"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.byte_start;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("byte_start"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Code<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"code"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for DidMention<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"didMention"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Footnote<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"footnote"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Highlight<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"highlight"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Id<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"id"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Italic<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"italic"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Link<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"link"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Facet<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Strikethrough<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"strikethrough"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Underline<'a> {
fn nsid() -> &'static str {
"pub.leaflet.richtext.facet"
}
fn def_name() -> &'static str {
"underline"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_richtext_facet()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod at_mention_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 AtUri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type AtUri = Unset;
}
pub struct SetAtUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAtUri<S> {}
impl<S: State> State for SetAtUri<S> {
type AtUri = Set<members::at_uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct at_uri(());
}
}
pub struct AtMentionBuilder<'a, S: at_mention_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<UriValue<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> AtMention<'a> {
pub fn new() -> AtMentionBuilder<'a, at_mention_state::Empty> {
AtMentionBuilder::new()
}
}
impl<'a> AtMentionBuilder<'a, at_mention_state::Empty> {
pub fn new() -> Self {
AtMentionBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> AtMentionBuilder<'a, S>
where
S: at_mention_state::State,
S::AtUri: at_mention_state::IsUnset,
{
pub fn at_uri(
mut self,
value: impl Into<UriValue<'a>>,
) -> AtMentionBuilder<'a, at_mention_state::SetAtUri<S>> {
self._fields.0 = Option::Some(value.into());
AtMentionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AtMentionBuilder<'a, S>
where
S: at_mention_state::State,
S::AtUri: at_mention_state::IsSet,
{
pub fn build(self) -> AtMention<'a> {
AtMention {
at_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>,
>,
) -> AtMention<'a> {
AtMention {
at_uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_pub_leaflet_richtext_facet() -> 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("pub.leaflet.richtext.facet"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("atMention"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for mentioning an AT URI."),
),
required: Some(vec![SmolStr::new_static("atURI")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("atURI"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bold"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Facet feature for bold text")),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("byteSlice"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.",
),
),
required: Some(
vec![
SmolStr::new_static("byteStart"),
SmolStr::new_static("byteEnd")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("byteEnd"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("byteStart"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("code"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for inline code."),
),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("didMention"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for mentioning a did."),
),
required: Some(vec![SmolStr::new_static("did")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("footnote"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for a footnote reference"),
),
required: Some(
vec![
SmolStr::new_static("footnoteId"),
SmolStr::new_static("contentPlaintext")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("contentFacets"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#main"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contentPlaintext"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("footnoteId"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("highlight"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for highlighted text."),
),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Facet feature for an identifier. Used for linking to a segment",
),
),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("italic"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for italic text"),
),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("link"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.",
),
),
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 { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Annotation of a sub-string within rich text.",
),
),
required: Some(
vec![
SmolStr::new_static("index"), SmolStr::new_static("features")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("features"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#link"),
CowStr::new_static("#didMention"),
CowStr::new_static("#atMention"),
CowStr::new_static("#code"),
CowStr::new_static("#highlight"),
CowStr::new_static("#underline"),
CowStr::new_static("#strikethrough"),
CowStr::new_static("#id"), CowStr::new_static("#bold"),
CowStr::new_static("#italic"),
CowStr::new_static("#footnote")
],
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("index"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#byteSlice"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("strikethrough"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for strikethrough markup"),
),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("underline"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for underline markup"),
),
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod byte_slice_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 ByteStart;
type ByteEnd;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ByteStart = Unset;
type ByteEnd = Unset;
}
pub struct SetByteStart<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetByteStart<S> {}
impl<S: State> State for SetByteStart<S> {
type ByteStart = Set<members::byte_start>;
type ByteEnd = S::ByteEnd;
}
pub struct SetByteEnd<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetByteEnd<S> {}
impl<S: State> State for SetByteEnd<S> {
type ByteStart = S::ByteStart;
type ByteEnd = Set<members::byte_end>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct byte_start(());
pub struct byte_end(());
}
}
pub struct ByteSliceBuilder<'a, S: byte_slice_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ByteSlice<'a> {
pub fn new() -> ByteSliceBuilder<'a, byte_slice_state::Empty> {
ByteSliceBuilder::new()
}
}
impl<'a> ByteSliceBuilder<'a, byte_slice_state::Empty> {
pub fn new() -> Self {
ByteSliceBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ByteSliceBuilder<'a, S>
where
S: byte_slice_state::State,
S::ByteEnd: byte_slice_state::IsUnset,
{
pub fn byte_end(
mut self,
value: impl Into<i64>,
) -> ByteSliceBuilder<'a, byte_slice_state::SetByteEnd<S>> {
self._fields.0 = Option::Some(value.into());
ByteSliceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ByteSliceBuilder<'a, S>
where
S: byte_slice_state::State,
S::ByteStart: byte_slice_state::IsUnset,
{
pub fn byte_start(
mut self,
value: impl Into<i64>,
) -> ByteSliceBuilder<'a, byte_slice_state::SetByteStart<S>> {
self._fields.1 = Option::Some(value.into());
ByteSliceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ByteSliceBuilder<'a, S>
where
S: byte_slice_state::State,
S::ByteStart: byte_slice_state::IsSet,
S::ByteEnd: byte_slice_state::IsSet,
{
pub fn build(self) -> ByteSlice<'a> {
ByteSlice {
byte_end: self._fields.0.unwrap(),
byte_start: self._fields.1.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>,
>,
) -> ByteSlice<'a> {
ByteSlice {
byte_end: self._fields.0.unwrap(),
byte_start: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod did_mention_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 Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct DidMentionBuilder<'a, S: did_mention_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Did<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> DidMention<'a> {
pub fn new() -> DidMentionBuilder<'a, did_mention_state::Empty> {
DidMentionBuilder::new()
}
}
impl<'a> DidMentionBuilder<'a, did_mention_state::Empty> {
pub fn new() -> Self {
DidMentionBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> DidMentionBuilder<'a, S>
where
S: did_mention_state::State,
S::Did: did_mention_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> DidMentionBuilder<'a, did_mention_state::SetDid<S>> {
self._fields.0 = Option::Some(value.into());
DidMentionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> DidMentionBuilder<'a, S>
where
S: did_mention_state::State,
S::Did: did_mention_state::IsSet,
{
pub fn build(self) -> DidMention<'a> {
DidMention {
did: 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>,
>,
) -> DidMention<'a> {
DidMention {
did: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod facet_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 Index;
type Features;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Index = Unset;
type Features = Unset;
}
pub struct SetIndex<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIndex<S> {}
impl<S: State> State for SetIndex<S> {
type Index = Set<members::index>;
type Features = S::Features;
}
pub struct SetFeatures<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetFeatures<S> {}
impl<S: State> State for SetFeatures<S> {
type Index = S::Index;
type Features = Set<members::features>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct index(());
pub struct features(());
}
}
pub struct FacetBuilder<'a, S: facet_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<FacetFeaturesItem<'a>>>, Option<facet::ByteSlice<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Facet<'a> {
pub fn new() -> FacetBuilder<'a, facet_state::Empty> {
FacetBuilder::new()
}
}
impl<'a> FacetBuilder<'a, facet_state::Empty> {
pub fn new() -> Self {
FacetBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> FacetBuilder<'a, S>
where
S: facet_state::State,
S::Features: facet_state::IsUnset,
{
pub fn features(
mut self,
value: impl Into<Vec<FacetFeaturesItem<'a>>>,
) -> FacetBuilder<'a, facet_state::SetFeatures<S>> {
self._fields.0 = Option::Some(value.into());
FacetBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FacetBuilder<'a, S>
where
S: facet_state::State,
S::Index: facet_state::IsUnset,
{
pub fn index(
mut self,
value: impl Into<facet::ByteSlice<'a>>,
) -> FacetBuilder<'a, facet_state::SetIndex<S>> {
self._fields.1 = Option::Some(value.into());
FacetBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FacetBuilder<'a, S>
where
S: facet_state::State,
S::Index: facet_state::IsSet,
S::Features: facet_state::IsSet,
{
pub fn build(self) -> Facet<'a> {
Facet {
features: self._fields.0.unwrap(),
index: self._fields.1.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>,
>,
) -> Facet<'a> {
Facet {
features: self._fields.0.unwrap(),
index: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}