#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, 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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Nsid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_bsky::richtext::facet::Facet;
use crate::garden_lexicon::exultant_zebra::masl::Masl;
use crate::garden_lexicon::exultant_zebra::masl::Resource;
use crate::garden_lexicon::exultant_zebra::tile;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Interactions<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub collections: Option<Vec<Nsid<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub methods: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<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",
rename = "garden.lexicon.exultant-zebra.tile",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Tile<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub aspect_ratio: Option<TileAspectRatio<S>>,
pub content: TileContent<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<Facet<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon: Option<BlobRef<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub interactions: Option<tile::Interactions<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub loading_image: Option<BlobRef<S>>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub params: Option<Vec<tile::Param<S>>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TileAspectRatio<S: BosStr = DefaultStr> {
_11,
_21,
_31,
_12,
_13,
Other(S),
}
impl<S: BosStr> TileAspectRatio<S> {
pub fn as_str(&self) -> &str {
match self {
Self::_11 => "1:1",
Self::_21 => "2:1",
Self::_31 => "3:1",
Self::_12 => "1:2",
Self::_13 => "1:3",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"1:1" => Self::_11,
"2:1" => Self::_21,
"3:1" => Self::_31,
"1:2" => Self::_12,
"1:3" => Self::_13,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for TileAspectRatio<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for TileAspectRatio<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for TileAspectRatio<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for TileAspectRatio<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for TileAspectRatio<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for TileAspectRatio<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = TileAspectRatio<S::Output>;
fn into_static(self) -> Self::Output {
match self {
TileAspectRatio::_11 => TileAspectRatio::_11,
TileAspectRatio::_21 => TileAspectRatio::_21,
TileAspectRatio::_31 => TileAspectRatio::_31,
TileAspectRatio::_12 => TileAspectRatio::_12,
TileAspectRatio::_13 => TileAspectRatio::_13,
TileAspectRatio::Other(v) => TileAspectRatio::Other(v.into_static()),
}
}
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum TileContent<S: BosStr = DefaultStr> {
#[serde(rename = "garden.lexicon.exultant-zebra.masl#resource")]
MaslResource(Box<Resource<S>>),
#[serde(rename = "garden.lexicon.exultant-zebra.masl#main")]
Masl(Box<Masl<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TileGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Tile<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Param<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub required: Option<bool>,
pub r#type: ParamType<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParamType<S: BosStr = DefaultStr> {
String,
Integer,
Boolean,
Other(S),
}
impl<S: BosStr> ParamType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::String => "string",
Self::Integer => "integer",
Self::Boolean => "boolean",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"string" => Self::String,
"integer" => Self::Integer,
"boolean" => Self::Boolean,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ParamType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ParamType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ParamType<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for ParamType<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for ParamType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ParamType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ParamType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ParamType::String => ParamType::String,
ParamType::Integer => ParamType::Integer,
ParamType::Boolean => ParamType::Boolean,
ParamType::Other(v) => ParamType::Other(v.into_static()),
}
}
}
impl<S: BosStr> Tile<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, TileRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Interactions<S> {
fn nsid() -> &'static str {
"garden.lexicon.exultant-zebra.tile"
}
fn def_name() -> &'static str {
"interactions"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_garden_lexicon_exultant_zebra_tile()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct TileRecord;
impl XrpcResp for TileRecord {
const NSID: &'static str = "garden.lexicon.exultant-zebra.tile";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = TileGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<TileGetRecordOutput<S>> for Tile<S> {
fn from(output: TileGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Tile<S> {
const NSID: &'static str = "garden.lexicon.exultant-zebra.tile";
type Record = TileRecord;
}
impl Collection for TileRecord {
const NSID: &'static str = "garden.lexicon.exultant-zebra.tile";
type Record = TileRecord;
}
impl<S: BosStr> LexiconSchema for Tile<S> {
fn nsid() -> &'static str {
"garden.lexicon.exultant-zebra.tile"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_garden_lexicon_exultant_zebra_tile()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.icon {
{
let size = value.blob().size;
if size > 1048576usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("icon"),
max: 1048576usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.icon {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
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("icon"),
accepted: vec!["image/png".to_string(), "image/jpeg".to_string()],
actual: mime.to_string(),
});
}
}
}
if let Some(ref value) = self.loading_image {
{
let size = value.blob().size;
if size > 1048576usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("loading_image"),
max: 1048576usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.loading_image {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
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("loading_image"),
accepted: vec!["image/png".to_string(), "image/jpeg".to_string()],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Param<S> {
fn nsid() -> &'static str {
"garden.lexicon.exultant-zebra.tile"
}
fn def_name() -> &'static str {
"param"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_garden_lexicon_exultant_zebra_tile()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_garden_lexicon_exultant_zebra_tile() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("garden.lexicon.exultant-zebra.tile"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("interactions"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Declares the AT Protocol interactions a tile performs. Methods listed here gate which XRPC calls the tile is allowed to attempt (the user must still grant per-method consent). Collections and services are informational metadata for display and auditing.",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collections"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Repository collection NSIDs this tile reads from or writes to.",
),
),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Nsid),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("methods"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"XRPC method NSIDs this tile may call. When present, the tile runtime restricts XRPC calls to only these methods. When absent, all server-allowed methods may be called (with user consent).",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("services"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"AT Protocol service proxy targets this tile interacts with, identified by DID and service endpoint fragment.",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A tile with a name and associated resource or bundle.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("content")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("aspectRatio"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Declared aspect ratio for tile rendering.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"The tile content, either a single resource or a bundle.",
),
),
refs: vec![
CowStr::new_static("garden.lexicon.exultant-zebra.masl#resource"),
CowStr::new_static("garden.lexicon.exultant-zebra.masl#main")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Optional rich text description of the tile.",
),
),
max_length: Some(3000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Rich text facets for the description (links, mentions, hashtags).",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("app.bsky.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("icon"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("interactions"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#interactions"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("loadingImage"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The name of the tile."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("params"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Input parameters this tile accepts. When present, the tile runtime shows a configuration form for required parameters without defaults before loading the tile.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#param"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("param"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Declares an input parameter for a tile, similar to XRPC query parameters.",
),
),
required: Some(
vec![SmolStr::new_static("name"), SmolStr::new_static("type")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("default"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Default value for this parameter, encoded as a string.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Human-readable description of this parameter.",
),
),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Parameter name, used as a URL search param key. Must not start with an underscore.",
),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("required"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Parameter value type."),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod tile_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Content;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Content = Unset;
type Name = Unset;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Content = Set<members::content>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Content = St::Content;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content(());
pub struct name(());
}
}
pub struct TileBuilder<S: BosStr, St: tile_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<TileAspectRatio<S>>,
Option<TileContent<S>>,
Option<S>,
Option<Vec<Facet<S>>>,
Option<BlobRef<S>>,
Option<tile::Interactions<S>>,
Option<BlobRef<S>>,
Option<S>,
Option<Vec<tile::Param<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Tile<S> {
pub fn new() -> TileBuilder<S, tile_state::Empty> {
TileBuilder::new()
}
}
impl<S: BosStr> TileBuilder<S, tile_state::Empty> {
pub fn new() -> Self {
TileBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn aspect_ratio(mut self, value: impl Into<Option<TileAspectRatio<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_aspect_ratio(mut self, value: Option<TileAspectRatio<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> TileBuilder<S, St>
where
St: tile_state::State,
St::Content: tile_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<TileContent<S>>,
) -> TileBuilder<S, tile_state::SetContent<St>> {
self._fields.1 = Option::Some(value.into());
TileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn icon(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_icon(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn interactions(mut self, value: impl Into<Option<tile::Interactions<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_interactions(mut self, value: Option<tile::Interactions<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn loading_image(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_loading_image(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> TileBuilder<S, St>
where
St: tile_state::State,
St::Name: tile_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> TileBuilder<S, tile_state::SetName<St>> {
self._fields.7 = Option::Some(value.into());
TileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: tile_state::State> TileBuilder<S, St> {
pub fn params(mut self, value: impl Into<Option<Vec<tile::Param<S>>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_params(mut self, value: Option<Vec<tile::Param<S>>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> TileBuilder<S, St>
where
St: tile_state::State,
St::Content: tile_state::IsSet,
St::Name: tile_state::IsSet,
{
pub fn build(self) -> Tile<S> {
Tile {
aspect_ratio: self._fields.0,
content: self._fields.1.unwrap(),
description: self._fields.2,
facets: self._fields.3,
icon: self._fields.4,
interactions: self._fields.5,
loading_image: self._fields.6,
name: self._fields.7.unwrap(),
params: self._fields.8,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Tile<S> {
Tile {
aspect_ratio: self._fields.0,
content: self._fields.1.unwrap(),
description: self._fields.2,
facets: self._fields.3,
icon: self._fields.4,
interactions: self._fields.5,
loading_image: self._fields.6,
name: self._fields.7.unwrap(),
params: self._fields.8,
extra_data: Some(extra_data),
}
}
}