#[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, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_dropanchor::checkin;
#[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 Address<S: BosStr = DefaultStr> {
pub country: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub locality: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub postal_code: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub street: 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 CheckinImage<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
pub fullsize: BlobRef<S>,
pub thumb: BlobRef<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 FsqPlace<S: BosStr = DefaultStr> {
pub fsq_place_id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub latitude: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub longitude: Option<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 Geo<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub altitude: Option<S>,
pub latitude: S,
pub longitude: 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)]
#[serde(
rename_all = "camelCase",
rename = "app.dropanchor.checkin",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Checkin<S: BosStr = DefaultStr> {
pub address: checkin::Address<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub category_group: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub category_icon: Option<S>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub fsq: Option<checkin::FsqPlace<S>>,
pub geo: checkin::Geo<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub image: Option<checkin::CheckinImage<S>>,
pub text: 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")]
pub struct CheckinGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Checkin<S>,
}
impl<S: BosStr> Checkin<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CheckinRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Address<S> {
fn nsid() -> &'static str {
"app.dropanchor.checkin"
}
fn def_name() -> &'static str {
"address"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_dropanchor_checkin()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.country;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("country"),
max: 10usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.country;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 2usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("country"),
min: 2usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.locality {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("locality"),
max: 200usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 500usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.postal_code {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("postal_code"),
max: 20usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.region {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("region"),
max: 200usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.street {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("street"),
max: 500usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CheckinImage<S> {
fn nsid() -> &'static str {
"app.dropanchor.checkin"
}
fn def_name() -> &'static str {
"checkinImage"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_dropanchor_checkin()
}
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.fullsize;
{
let size = value.blob().size;
if size > 2000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("fullsize"),
max: 2000000usize,
actual: size,
});
}
}
}
{
let value = &self.fullsize;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/jpeg", "image/png", "image/webp"];
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("fullsize"),
accepted: vec![
"image/jpeg".to_string(),
"image/png".to_string(),
"image/webp".to_string(),
],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.thumb;
{
let size = value.blob().size;
if size > 300000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("thumb"),
max: 300000usize,
actual: size,
});
}
}
}
{
let value = &self.thumb;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/jpeg", "image/png", "image/webp"];
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("thumb"),
accepted: vec![
"image/jpeg".to_string(),
"image/png".to_string(),
"image/webp".to_string(),
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for FsqPlace<S> {
fn nsid() -> &'static str {
"app.dropanchor.checkin"
}
fn def_name() -> &'static str {
"fsqPlace"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_dropanchor_checkin()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.fsq_place_id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("fsq_place_id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.latitude {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("latitude"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.longitude {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("longitude"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 500usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Geo<S> {
fn nsid() -> &'static str {
"app.dropanchor.checkin"
}
fn def_name() -> &'static str {
"geo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_dropanchor_checkin()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.altitude {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("altitude"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.latitude;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("latitude"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.longitude;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("longitude"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 500usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CheckinRecord;
impl XrpcResp for CheckinRecord {
const NSID: &'static str = "app.dropanchor.checkin";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CheckinGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CheckinGetRecordOutput<S>> for Checkin<S> {
fn from(output: CheckinGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Checkin<S> {
const NSID: &'static str = "app.dropanchor.checkin";
type Record = CheckinRecord;
}
impl Collection for CheckinRecord {
const NSID: &'static str = "app.dropanchor.checkin";
type Record = CheckinRecord;
}
impl<S: BosStr> LexiconSchema for Checkin<S> {
fn nsid() -> &'static str {
"app.dropanchor.checkin"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_dropanchor_checkin()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.category {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("category"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.category_group {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("category_group"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.category_icon {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("category_icon"),
max: 10usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_app_dropanchor_checkin() -> 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("app.dropanchor.checkin"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("address"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Street address (based on community.lexicon.location.address)",
)),
required: Some(vec![SmolStr::new_static("country")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("country"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The ISO 3166 country code (preferably 2-letter)",
)),
min_length: Some(2usize),
max_length: Some(10usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("locality"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The locality (city, town, etc.)",
)),
max_length: Some(200usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The name of the location")),
max_length: Some(500usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postalCode"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The postal code")),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("region"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The administrative region (state, province, etc.)",
)),
max_length: Some(200usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("street"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The street address")),
max_length: Some(500usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("checkinImage"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Image attachment with thumbnail and full-size versions",
)),
required: Some(vec![
SmolStr::new_static("thumb"),
SmolStr::new_static("fullsize"),
]),
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("fullsize"),
LexObjectProperty::Blob(LexBlob {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("thumb"),
LexObjectProperty::Blob(LexBlob {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("fsqPlace"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Foursquare venue data (based on community.lexicon.location.fsq)",
)),
required: Some(vec![SmolStr::new_static("fsqPlaceId")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("fsqPlaceId"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The unique identifier of a Foursquare POI",
)),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("latitude"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Latitude in decimal degrees",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("longitude"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Longitude in decimal degrees",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The name of the location")),
max_length: Some(500usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("geo"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Geographic coordinates in WGS84 (based on community.lexicon.location.geo)",
)),
required: Some(vec![
SmolStr::new_static("latitude"),
SmolStr::new_static("longitude"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("altitude"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Altitude in meters")),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("latitude"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Latitude in decimal degrees (range: -90 to 90)",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("longitude"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Longitude in decimal degrees (range: -180 to 180)",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Name of the location")),
max_length: Some(500usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static(
"A location check-in record for the Anchor app",
)),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![
SmolStr::new_static("text"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("address"),
SmolStr::new_static("geo"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("address"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#address"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("category"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Place category (e.g., cafe, restaurant)",
)),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("categoryGroup"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Category group for organization",
)),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("categoryIcon"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Emoji icon for the category",
)),
max_length: Some(10usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"When the check-in was created",
)),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("fsq"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#fsqPlace"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("geo"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#geo"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("image"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#checkinImage"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The check-in message or note",
)),
max_length: Some(3000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod checkin_image_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 Fullsize;
type Thumb;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Fullsize = Unset;
type Thumb = Unset;
}
pub struct SetFullsize<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFullsize<St> {}
impl<St: State> State for SetFullsize<St> {
type Fullsize = Set<members::fullsize>;
type Thumb = St::Thumb;
}
pub struct SetThumb<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetThumb<St> {}
impl<St: State> State for SetThumb<St> {
type Fullsize = St::Fullsize;
type Thumb = Set<members::thumb>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct fullsize(());
pub struct thumb(());
}
}
pub struct CheckinImageBuilder<S: BosStr, St: checkin_image_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<BlobRef<S>>, Option<BlobRef<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CheckinImage<S> {
pub fn new() -> CheckinImageBuilder<S, checkin_image_state::Empty> {
CheckinImageBuilder::new()
}
}
impl<S: BosStr> CheckinImageBuilder<S, checkin_image_state::Empty> {
pub fn new() -> Self {
CheckinImageBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: checkin_image_state::State> CheckinImageBuilder<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> CheckinImageBuilder<S, St>
where
St: checkin_image_state::State,
St::Fullsize: checkin_image_state::IsUnset,
{
pub fn fullsize(
mut self,
value: impl Into<BlobRef<S>>,
) -> CheckinImageBuilder<S, checkin_image_state::SetFullsize<St>> {
self._fields.1 = Option::Some(value.into());
CheckinImageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CheckinImageBuilder<S, St>
where
St: checkin_image_state::State,
St::Thumb: checkin_image_state::IsUnset,
{
pub fn thumb(
mut self,
value: impl Into<BlobRef<S>>,
) -> CheckinImageBuilder<S, checkin_image_state::SetThumb<St>> {
self._fields.2 = Option::Some(value.into());
CheckinImageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CheckinImageBuilder<S, St>
where
St: checkin_image_state::State,
St::Fullsize: checkin_image_state::IsSet,
St::Thumb: checkin_image_state::IsSet,
{
pub fn build(self) -> CheckinImage<S> {
CheckinImage {
alt: self._fields.0,
fullsize: self._fields.1.unwrap(),
thumb: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CheckinImage<S> {
CheckinImage {
alt: self._fields.0,
fullsize: self._fields.1.unwrap(),
thumb: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod checkin_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 CreatedAt;
type Address;
type Text;
type Geo;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Address = Unset;
type Text = Unset;
type Geo = Unset;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type CreatedAt = Set<members::created_at>;
type Address = St::Address;
type Text = St::Text;
type Geo = St::Geo;
}
pub struct SetAddress<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAddress<St> {}
impl<St: State> State for SetAddress<St> {
type CreatedAt = St::CreatedAt;
type Address = Set<members::address>;
type Text = St::Text;
type Geo = St::Geo;
}
pub struct SetText<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetText<St> {}
impl<St: State> State for SetText<St> {
type CreatedAt = St::CreatedAt;
type Address = St::Address;
type Text = Set<members::text>;
type Geo = St::Geo;
}
pub struct SetGeo<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetGeo<St> {}
impl<St: State> State for SetGeo<St> {
type CreatedAt = St::CreatedAt;
type Address = St::Address;
type Text = St::Text;
type Geo = Set<members::geo>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct address(());
pub struct text(());
pub struct geo(());
}
}
pub struct CheckinBuilder<S: BosStr, St: checkin_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<checkin::Address<S>>,
Option<S>,
Option<S>,
Option<S>,
Option<Datetime>,
Option<checkin::FsqPlace<S>>,
Option<checkin::Geo<S>>,
Option<checkin::CheckinImage<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Checkin<S> {
pub fn new() -> CheckinBuilder<S, checkin_state::Empty> {
CheckinBuilder::new()
}
}
impl<S: BosStr> CheckinBuilder<S, checkin_state::Empty> {
pub fn new() -> Self {
CheckinBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CheckinBuilder<S, St>
where
St: checkin_state::State,
St::Address: checkin_state::IsUnset,
{
pub fn address(
mut self,
value: impl Into<checkin::Address<S>>,
) -> CheckinBuilder<S, checkin_state::SetAddress<St>> {
self._fields.0 = Option::Some(value.into());
CheckinBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: checkin_state::State> CheckinBuilder<S, St> {
pub fn category(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_category(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: checkin_state::State> CheckinBuilder<S, St> {
pub fn category_group(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_category_group(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: checkin_state::State> CheckinBuilder<S, St> {
pub fn category_icon(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_category_icon(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> CheckinBuilder<S, St>
where
St: checkin_state::State,
St::CreatedAt: checkin_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> CheckinBuilder<S, checkin_state::SetCreatedAt<St>> {
self._fields.4 = Option::Some(value.into());
CheckinBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: checkin_state::State> CheckinBuilder<S, St> {
pub fn fsq(mut self, value: impl Into<Option<checkin::FsqPlace<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_fsq(mut self, value: Option<checkin::FsqPlace<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St> CheckinBuilder<S, St>
where
St: checkin_state::State,
St::Geo: checkin_state::IsUnset,
{
pub fn geo(
mut self,
value: impl Into<checkin::Geo<S>>,
) -> CheckinBuilder<S, checkin_state::SetGeo<St>> {
self._fields.6 = Option::Some(value.into());
CheckinBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: checkin_state::State> CheckinBuilder<S, St> {
pub fn image(mut self, value: impl Into<Option<checkin::CheckinImage<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_image(mut self, value: Option<checkin::CheckinImage<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St> CheckinBuilder<S, St>
where
St: checkin_state::State,
St::Text: checkin_state::IsUnset,
{
pub fn text(mut self, value: impl Into<S>) -> CheckinBuilder<S, checkin_state::SetText<St>> {
self._fields.8 = Option::Some(value.into());
CheckinBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CheckinBuilder<S, St>
where
St: checkin_state::State,
St::CreatedAt: checkin_state::IsSet,
St::Address: checkin_state::IsSet,
St::Text: checkin_state::IsSet,
St::Geo: checkin_state::IsSet,
{
pub fn build(self) -> Checkin<S> {
Checkin {
address: self._fields.0.unwrap(),
category: self._fields.1,
category_group: self._fields.2,
category_icon: self._fields.3,
created_at: self._fields.4.unwrap(),
fsq: self._fields.5,
geo: self._fields.6.unwrap(),
image: self._fields.7,
text: self._fields.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Checkin<S> {
Checkin {
address: self._fields.0.unwrap(),
category: self._fields.1,
category_group: self._fields.2,
category_icon: self._fields.3,
created_at: self._fields.4.unwrap(),
fsq: self._fields.5,
geo: self._fields.6.unwrap(),
image: self._fields.7,
text: self._fields.8.unwrap(),
extra_data: Some(extra_data),
}
}
}