pub mod entry;
#[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::string::UriValue;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::app_greengale::blog;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BlobMetadata<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
pub blobref: BlobRef<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<blog::SelfLabels<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CustomColors<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub accent: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub background: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub code_background: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<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 Ogp<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
pub url: UriValue<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i64>,
#[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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SelfLabel<S: BosStr = DefaultStr> {
pub val: 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 SelfLabels<S: BosStr = DefaultStr> {
pub values: Vec<blog::SelfLabel<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Theme<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub custom: Option<blog::CustomColors<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub preset: Option<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct VoiceTheme<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub pitch: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub speed: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub voice: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for BlobMetadata<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"blobMetadata"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.alt {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("alt"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.blobref;
{
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("blobref"),
accepted: vec!["*/*".to_string()],
actual: mime.to_string(),
});
}
}
}
if let Some(ref value) = self.name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CustomColors<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"customColors"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.accent {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("accent"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.background {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("background"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.code_background {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("code_background"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.text {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Ogp<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"ogp"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.url;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2048usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("url"),
max: 2048usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SelfLabel<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"selfLabel"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.val;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("val"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SelfLabels<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"selfLabels"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.values;
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("values"),
max: 10usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Theme<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"theme"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.preset {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("preset"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for VoiceTheme<S> {
fn nsid() -> &'static str {
"app.greengale.blog.defs"
}
fn def_name() -> &'static str {
"voiceTheme"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_greengale_blog_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.voice {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("voice"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod blob_metadata_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 Blobref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blobref = Unset;
}
pub struct SetBlobref<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlobref<St> {}
impl<St: State> State for SetBlobref<St> {
type Blobref = Set<members::blobref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blobref(());
}
}
pub struct BlobMetadataBuilder<S: BosStr, St: blob_metadata_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<BlobRef<S>>, Option<blog::SelfLabels<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> BlobMetadata<S> {
pub fn new() -> BlobMetadataBuilder<S, blob_metadata_state::Empty> {
BlobMetadataBuilder::new()
}
}
impl<S: BosStr> BlobMetadataBuilder<S, blob_metadata_state::Empty> {
pub fn new() -> Self {
BlobMetadataBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: blob_metadata_state::State> BlobMetadataBuilder<S, St> {
pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> BlobMetadataBuilder<S, St>
where
St: blob_metadata_state::State,
St::Blobref: blob_metadata_state::IsUnset,
{
pub fn blobref(
mut self,
value: impl Into<BlobRef<S>>,
) -> BlobMetadataBuilder<S, blob_metadata_state::SetBlobref<St>> {
self._fields.1 = Option::Some(value.into());
BlobMetadataBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: blob_metadata_state::State> BlobMetadataBuilder<S, St> {
pub fn labels(mut self, value: impl Into<Option<blog::SelfLabels<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_labels(mut self, value: Option<blog::SelfLabels<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: blob_metadata_state::State> BlobMetadataBuilder<S, St> {
pub fn name(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_name(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> BlobMetadataBuilder<S, St>
where
St: blob_metadata_state::State,
St::Blobref: blob_metadata_state::IsSet,
{
pub fn build(self) -> BlobMetadata<S> {
BlobMetadata {
alt: self._fields.0,
blobref: self._fields.1.unwrap(),
labels: self._fields.2,
name: self._fields.3,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> BlobMetadata<S> {
BlobMetadata {
alt: self._fields.0,
blobref: self._fields.1.unwrap(),
labels: self._fields.2,
name: self._fields.3,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_greengale_blog_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("app.greengale.blog.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blobMetadata"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Metadata for uploaded binary content"),
),
required: Some(vec![SmolStr::new_static("blobref")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Alt text for accessibility"),
),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("blobref"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("labels"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#selfLabels"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Original filename")),
max_length: Some(256usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("customColors"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Custom color values (CSS color strings)"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("accent"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Accent/link color")),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("background"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Background color")),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codeBackground"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Code block background color"),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Primary text color")),
max_length: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ogp"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Open Graph Protocol metadata for social sharing",
),
),
required: Some(vec![SmolStr::new_static("url")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URL of the OGP image"),
),
format: Some(LexStringFormat::Uri),
max_length: Some(2048usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("selfLabel"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Metadata tag on an atproto resource, published by the author",
),
),
required: Some(vec![SmolStr::new_static("val")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("val"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The short string name of the value or type of this label",
),
),
max_length: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("selfLabels"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Metadata tags on an atproto resource, published by the author",
),
),
required: Some(vec![SmolStr::new_static("values")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("values"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#selfLabel"),
..Default::default()
}),
max_length: Some(10usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("theme"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Theme configuration for a blog entry"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("custom"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#customColors"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("preset"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Predefined color theme"),
),
max_length: Some(32usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("voiceTheme"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Voice theme configuration for TTS playback"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("pitch"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("speed"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("voice"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Voice ID for TTS (e.g., 'af_heart', 'am_adam')",
),
),
max_length: Some(32usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod ogp_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 Url;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Url = Unset;
}
pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUrl<St> {}
impl<St: State> State for SetUrl<St> {
type Url = Set<members::url>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct url(());
}
}
pub struct OgpBuilder<S: BosStr, St: ogp_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<UriValue<S>>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Ogp<S> {
pub fn new() -> OgpBuilder<S, ogp_state::Empty> {
OgpBuilder::new()
}
}
impl<S: BosStr> OgpBuilder<S, ogp_state::Empty> {
pub fn new() -> Self {
OgpBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: ogp_state::State> OgpBuilder<S, St> {
pub fn height(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_height(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> OgpBuilder<S, St>
where
St: ogp_state::State,
St::Url: ogp_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<UriValue<S>>,
) -> OgpBuilder<S, ogp_state::SetUrl<St>> {
self._fields.1 = Option::Some(value.into());
OgpBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: ogp_state::State> OgpBuilder<S, St> {
pub fn width(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_width(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> OgpBuilder<S, St>
where
St: ogp_state::State,
St::Url: ogp_state::IsSet,
{
pub fn build(self) -> Ogp<S> {
Ogp {
height: self._fields.0,
url: self._fields.1.unwrap(),
width: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Ogp<S> {
Ogp {
height: self._fields.0,
url: self._fields.1.unwrap(),
width: self._fields.2,
extra_data: Some(extra_data),
}
}
}
pub mod self_labels_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 Values;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Values = Unset;
}
pub struct SetValues<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValues<St> {}
impl<St: State> State for SetValues<St> {
type Values = Set<members::values>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct values(());
}
}
pub struct SelfLabelsBuilder<S: BosStr, St: self_labels_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<blog::SelfLabel<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SelfLabels<S> {
pub fn new() -> SelfLabelsBuilder<S, self_labels_state::Empty> {
SelfLabelsBuilder::new()
}
}
impl<S: BosStr> SelfLabelsBuilder<S, self_labels_state::Empty> {
pub fn new() -> Self {
SelfLabelsBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SelfLabelsBuilder<S, St>
where
St: self_labels_state::State,
St::Values: self_labels_state::IsUnset,
{
pub fn values(
mut self,
value: impl Into<Vec<blog::SelfLabel<S>>>,
) -> SelfLabelsBuilder<S, self_labels_state::SetValues<St>> {
self._fields.0 = Option::Some(value.into());
SelfLabelsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SelfLabelsBuilder<S, St>
where
St: self_labels_state::State,
St::Values: self_labels_state::IsSet,
{
pub fn build(self) -> SelfLabels<S> {
SelfLabels {
values: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> SelfLabels<S> {
SelfLabels {
values: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}