#[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::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;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "app.beaconbits.profile",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Profile<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_tags: Option<ProfileAllowTags<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default_delayed_reveal: Option<ProfileDefaultDelayedReveal<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default_visibility: Option<ProfileDefaultVisibility<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub distance_unit: Option<ProfileDistanceUnit<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_profile_hide_past_beacons")]
pub hide_past_beacons: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<ProfileLanguage<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub marker_color: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_profile_post_beacon_links")]
pub post_beacon_links: Option<bool>,
pub updated_at: Datetime,
#[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 ProfileAllowTags<S: BosStr = DefaultStr> {
All,
Followers,
Mutuals,
None,
Other(S),
}
impl<S: BosStr> ProfileAllowTags<S> {
pub fn as_str(&self) -> &str {
match self {
Self::All => "all",
Self::Followers => "followers",
Self::Mutuals => "mutuals",
Self::None => "none",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"all" => Self::All,
"followers" => Self::Followers,
"mutuals" => Self::Mutuals,
"none" => Self::None,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ProfileAllowTags<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ProfileAllowTags<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ProfileAllowTags<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 ProfileAllowTags<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 ProfileAllowTags<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ProfileAllowTags<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ProfileAllowTags<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ProfileAllowTags::All => ProfileAllowTags::All,
ProfileAllowTags::Followers => ProfileAllowTags::Followers,
ProfileAllowTags::Mutuals => ProfileAllowTags::Mutuals,
ProfileAllowTags::None => ProfileAllowTags::None,
ProfileAllowTags::Other(v) => ProfileAllowTags::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProfileDefaultDelayedReveal<S: BosStr = DefaultStr> {
None,
_1h,
_1d,
Custom,
Other(S),
}
impl<S: BosStr> ProfileDefaultDelayedReveal<S> {
pub fn as_str(&self) -> &str {
match self {
Self::None => "none",
Self::_1h => "1h",
Self::_1d => "1d",
Self::Custom => "custom",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"none" => Self::None,
"1h" => Self::_1h,
"1d" => Self::_1d,
"custom" => Self::Custom,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ProfileDefaultDelayedReveal<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ProfileDefaultDelayedReveal<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ProfileDefaultDelayedReveal<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 ProfileDefaultDelayedReveal<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 ProfileDefaultDelayedReveal<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ProfileDefaultDelayedReveal<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ProfileDefaultDelayedReveal<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ProfileDefaultDelayedReveal::None => ProfileDefaultDelayedReveal::None,
ProfileDefaultDelayedReveal::_1h => ProfileDefaultDelayedReveal::_1h,
ProfileDefaultDelayedReveal::_1d => ProfileDefaultDelayedReveal::_1d,
ProfileDefaultDelayedReveal::Custom => ProfileDefaultDelayedReveal::Custom,
ProfileDefaultDelayedReveal::Other(v) => {
ProfileDefaultDelayedReveal::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProfileDefaultVisibility<S: BosStr = DefaultStr> {
Public,
Followers,
Mutuals,
Hidden,
Other(S),
}
impl<S: BosStr> ProfileDefaultVisibility<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Public => "public",
Self::Followers => "followers",
Self::Mutuals => "mutuals",
Self::Hidden => "hidden",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"public" => Self::Public,
"followers" => Self::Followers,
"mutuals" => Self::Mutuals,
"hidden" => Self::Hidden,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ProfileDefaultVisibility<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ProfileDefaultVisibility<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ProfileDefaultVisibility<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 ProfileDefaultVisibility<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 ProfileDefaultVisibility<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ProfileDefaultVisibility<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ProfileDefaultVisibility<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ProfileDefaultVisibility::Public => ProfileDefaultVisibility::Public,
ProfileDefaultVisibility::Followers => ProfileDefaultVisibility::Followers,
ProfileDefaultVisibility::Mutuals => ProfileDefaultVisibility::Mutuals,
ProfileDefaultVisibility::Hidden => ProfileDefaultVisibility::Hidden,
ProfileDefaultVisibility::Other(v) => {
ProfileDefaultVisibility::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProfileDistanceUnit<S: BosStr = DefaultStr> {
Km,
Miles,
Other(S),
}
impl<S: BosStr> ProfileDistanceUnit<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Km => "km",
Self::Miles => "miles",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"km" => Self::Km,
"miles" => Self::Miles,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ProfileDistanceUnit<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ProfileDistanceUnit<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ProfileDistanceUnit<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 ProfileDistanceUnit<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 ProfileDistanceUnit<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ProfileDistanceUnit<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ProfileDistanceUnit<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ProfileDistanceUnit::Km => ProfileDistanceUnit::Km,
ProfileDistanceUnit::Miles => ProfileDistanceUnit::Miles,
ProfileDistanceUnit::Other(v) => ProfileDistanceUnit::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProfileLanguage<S: BosStr = DefaultStr> {
Auto,
En,
Es,
Fr,
De,
PtBr,
Ja,
ZhHans,
Ko,
Other(S),
}
impl<S: BosStr> ProfileLanguage<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Auto => "auto",
Self::En => "en",
Self::Es => "es",
Self::Fr => "fr",
Self::De => "de",
Self::PtBr => "pt-BR",
Self::Ja => "ja",
Self::ZhHans => "zh-Hans",
Self::Ko => "ko",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"auto" => Self::Auto,
"en" => Self::En,
"es" => Self::Es,
"fr" => Self::Fr,
"de" => Self::De,
"pt-BR" => Self::PtBr,
"ja" => Self::Ja,
"zh-Hans" => Self::ZhHans,
"ko" => Self::Ko,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ProfileLanguage<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ProfileLanguage<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ProfileLanguage<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 ProfileLanguage<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 ProfileLanguage<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ProfileLanguage<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ProfileLanguage<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ProfileLanguage::Auto => ProfileLanguage::Auto,
ProfileLanguage::En => ProfileLanguage::En,
ProfileLanguage::Es => ProfileLanguage::Es,
ProfileLanguage::Fr => ProfileLanguage::Fr,
ProfileLanguage::De => ProfileLanguage::De,
ProfileLanguage::PtBr => ProfileLanguage::PtBr,
ProfileLanguage::Ja => ProfileLanguage::Ja,
ProfileLanguage::ZhHans => ProfileLanguage::ZhHans,
ProfileLanguage::Ko => ProfileLanguage::Ko,
ProfileLanguage::Other(v) => ProfileLanguage::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ProfileGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Profile<S>,
}
impl<S: BosStr> Profile<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, ProfileRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ProfileRecord;
impl XrpcResp for ProfileRecord {
const NSID: &'static str = "app.beaconbits.profile";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ProfileGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<ProfileGetRecordOutput<S>> for Profile<S> {
fn from(output: ProfileGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Profile<S> {
const NSID: &'static str = "app.beaconbits.profile";
type Record = ProfileRecord;
}
impl Collection for ProfileRecord {
const NSID: &'static str = "app.beaconbits.profile";
type Record = ProfileRecord;
}
impl<S: BosStr> LexiconSchema for Profile<S> {
fn nsid() -> &'static str {
"app.beaconbits.profile"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_beaconbits_profile()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.allow_tags {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 32usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("allow_tags"),
max: 32usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.default_delayed_reveal {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 16usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("default_delayed_reveal"),
max: 16usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.default_visibility {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 32usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("default_visibility"),
max: 32usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.distance_unit {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 16usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("distance_unit"),
max: 16usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.language {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 16usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("language"),
max: 16usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.marker_color {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 7usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("marker_color"),
max: 7usize,
actual: count,
});
}
}
}
Ok(())
}
}
fn _default_profile_hide_past_beacons() -> Option<bool> {
Some(false)
}
fn _default_profile_post_beacon_links() -> Option<bool> {
Some(true)
}
pub mod profile_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 UpdatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type UpdatedAt = Unset;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type UpdatedAt = Set<members::updated_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct updated_at(());
}
}
pub struct ProfileBuilder<S: BosStr, St: profile_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ProfileAllowTags<S>>,
Option<Datetime>,
Option<ProfileDefaultDelayedReveal<S>>,
Option<ProfileDefaultVisibility<S>>,
Option<ProfileDistanceUnit<S>>,
Option<bool>,
Option<ProfileLanguage<S>>,
Option<S>,
Option<bool>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Profile<S> {
pub fn new() -> ProfileBuilder<S, profile_state::Empty> {
ProfileBuilder::new()
}
}
impl<S: BosStr> ProfileBuilder<S, profile_state::Empty> {
pub fn new() -> Self {
ProfileBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn allow_tags(mut self, value: impl Into<Option<ProfileAllowTags<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_allow_tags(mut self, value: Option<ProfileAllowTags<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn default_delayed_reveal(
mut self,
value: impl Into<Option<ProfileDefaultDelayedReveal<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_default_delayed_reveal(
mut self,
value: Option<ProfileDefaultDelayedReveal<S>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn default_visibility(
mut self,
value: impl Into<Option<ProfileDefaultVisibility<S>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_default_visibility(
mut self,
value: Option<ProfileDefaultVisibility<S>>,
) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn distance_unit(
mut self,
value: impl Into<Option<ProfileDistanceUnit<S>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_distance_unit(mut self, value: Option<ProfileDistanceUnit<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn hide_past_beacons(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_hide_past_beacons(mut self, value: Option<bool>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn language(mut self, value: impl Into<Option<ProfileLanguage<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_language(mut self, value: Option<ProfileLanguage<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn marker_color(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_marker_color(mut self, value: Option<S>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: profile_state::State> ProfileBuilder<S, St> {
pub fn post_beacon_links(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_post_beacon_links(mut self, value: Option<bool>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> ProfileBuilder<S, St>
where
St: profile_state::State,
St::UpdatedAt: profile_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> ProfileBuilder<S, profile_state::SetUpdatedAt<St>> {
self._fields.9 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ProfileBuilder<S, St>
where
St: profile_state::State,
St::UpdatedAt: profile_state::IsSet,
{
pub fn build(self) -> Profile<S> {
Profile {
allow_tags: self._fields.0,
created_at: self._fields.1,
default_delayed_reveal: self._fields.2,
default_visibility: self._fields.3,
distance_unit: self._fields.4,
hide_past_beacons: self._fields.5.or_else(|| Some(false)),
language: self._fields.6,
marker_color: self._fields.7,
post_beacon_links: self._fields.8.or_else(|| Some(true)),
updated_at: self._fields.9.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Profile<S> {
Profile {
allow_tags: self._fields.0,
created_at: self._fields.1,
default_delayed_reveal: self._fields.2,
default_visibility: self._fields.3,
distance_unit: self._fields.4,
hide_past_beacons: self._fields.5.or_else(|| Some(false)),
language: self._fields.6,
marker_color: self._fields.7,
post_beacon_links: self._fields.8.or_else(|| Some(true)),
updated_at: self._fields.9.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_beaconbits_profile() -> 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.beaconbits.profile"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"User preferences and settings for BeaconBits",
),
),
key: Some(CowStr::new_static("literal:self")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![SmolStr::new_static("updatedAt")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("allowTags"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Who can tag this user in beacons"),
),
max_graphemes: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp when settings were first created",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("defaultDelayedReveal"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Default delayed reveal setting for new beacons",
),
),
max_graphemes: Some(16usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("defaultVisibility"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Default visibility for new beacons"),
),
max_graphemes: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("distanceUnit"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Preferred distance unit"),
),
max_graphemes: Some(16usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hidePastBeacons"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("language"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Preferred language setting"),
),
max_graphemes: Some(16usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("markerColor"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Hex color code for map marker (e.g., #e24630)",
),
),
max_graphemes: Some(7usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postBeaconLinks"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp when settings were last updated",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}