#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
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};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Profile<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub allow_tags: Option<ProfileAllowTags<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub default_delayed_reveal: Option<ProfileDefaultDelayedReveal<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub default_visibility: Option<ProfileDefaultVisibility<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub distance_unit: Option<ProfileDistanceUnit<'a>>,
#[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")]
#[serde(borrow)]
pub language: Option<ProfileLanguage<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub marker_color: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_profile_post_beacon_links")]
pub post_beacon_links: Option<bool>,
pub updated_at: Datetime,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProfileAllowTags<'a> {
All,
Followers,
Mutuals,
None,
Other(CowStr<'a>),
}
impl<'a> ProfileAllowTags<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for ProfileAllowTags<'a> {
fn from(s: &'a str) -> Self {
match s {
"all" => Self::All,
"followers" => Self::Followers,
"mutuals" => Self::Mutuals,
"none" => Self::None,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ProfileAllowTags<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"all" => Self::All,
"followers" => Self::Followers,
"mutuals" => Self::Mutuals,
"none" => Self::None,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ProfileAllowTags<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ProfileAllowTags<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ProfileAllowTags<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for ProfileAllowTags<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for ProfileAllowTags<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ProfileAllowTags<'_> {
type Output = ProfileAllowTags<'static>;
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<'a> {
None,
_1h,
_1d,
Custom,
Other(CowStr<'a>),
}
impl<'a> ProfileDefaultDelayedReveal<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for ProfileDefaultDelayedReveal<'a> {
fn from(s: &'a str) -> Self {
match s {
"none" => Self::None,
"1h" => Self::_1h,
"1d" => Self::_1d,
"custom" => Self::Custom,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ProfileDefaultDelayedReveal<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"none" => Self::None,
"1h" => Self::_1h,
"1d" => Self::_1d,
"custom" => Self::Custom,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ProfileDefaultDelayedReveal<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ProfileDefaultDelayedReveal<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ProfileDefaultDelayedReveal<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for ProfileDefaultDelayedReveal<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for ProfileDefaultDelayedReveal<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ProfileDefaultDelayedReveal<'_> {
type Output = ProfileDefaultDelayedReveal<'static>;
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<'a> {
Public,
Followers,
Mutuals,
Hidden,
Other(CowStr<'a>),
}
impl<'a> ProfileDefaultVisibility<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for ProfileDefaultVisibility<'a> {
fn from(s: &'a str) -> Self {
match s {
"public" => Self::Public,
"followers" => Self::Followers,
"mutuals" => Self::Mutuals,
"hidden" => Self::Hidden,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ProfileDefaultVisibility<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"public" => Self::Public,
"followers" => Self::Followers,
"mutuals" => Self::Mutuals,
"hidden" => Self::Hidden,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ProfileDefaultVisibility<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ProfileDefaultVisibility<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ProfileDefaultVisibility<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for ProfileDefaultVisibility<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for ProfileDefaultVisibility<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ProfileDefaultVisibility<'_> {
type Output = ProfileDefaultVisibility<'static>;
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<'a> {
Km,
Miles,
Other(CowStr<'a>),
}
impl<'a> ProfileDistanceUnit<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Km => "km",
Self::Miles => "miles",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for ProfileDistanceUnit<'a> {
fn from(s: &'a str) -> Self {
match s {
"km" => Self::Km,
"miles" => Self::Miles,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ProfileDistanceUnit<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"km" => Self::Km,
"miles" => Self::Miles,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ProfileDistanceUnit<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ProfileDistanceUnit<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ProfileDistanceUnit<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for ProfileDistanceUnit<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for ProfileDistanceUnit<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ProfileDistanceUnit<'_> {
type Output = ProfileDistanceUnit<'static>;
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<'a> {
Auto,
En,
Es,
Fr,
De,
PtBr,
Ja,
ZhHans,
Ko,
Other(CowStr<'a>),
}
impl<'a> ProfileLanguage<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for ProfileLanguage<'a> {
fn from(s: &'a str) -> Self {
match s {
"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(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ProfileLanguage<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"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(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ProfileLanguage<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ProfileLanguage<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ProfileLanguage<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for ProfileLanguage<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for ProfileLanguage<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ProfileLanguage<'_> {
type Output = ProfileLanguage<'static>;
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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Profile<'a>,
}
impl<'a> Profile<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, ProfileRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = ProfileGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<ProfileGetRecordOutput<'_>> for Profile<'_> {
fn from(output: ProfileGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Profile<'_> {
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<'a> LexiconSchema for Profile<'a> {
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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
impl<S: State> State for SetUpdatedAt<S> {
type UpdatedAt = Set<members::updated_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct updated_at(());
}
}
pub struct ProfileBuilder<'a, S: profile_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ProfileAllowTags<'a>>,
Option<Datetime>,
Option<ProfileDefaultDelayedReveal<'a>>,
Option<ProfileDefaultVisibility<'a>>,
Option<ProfileDistanceUnit<'a>>,
Option<bool>,
Option<ProfileLanguage<'a>>,
Option<CowStr<'a>>,
Option<bool>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Profile<'a> {
pub fn new() -> ProfileBuilder<'a, profile_state::Empty> {
ProfileBuilder::new()
}
}
impl<'a> ProfileBuilder<'a, profile_state::Empty> {
pub fn new() -> Self {
ProfileBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn allow_tags(mut self, value: impl Into<Option<ProfileAllowTags<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_allow_tags(mut self, value: Option<ProfileAllowTags<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
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<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn default_delayed_reveal(
mut self,
value: impl Into<Option<ProfileDefaultDelayedReveal<'a>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_default_delayed_reveal(
mut self,
value: Option<ProfileDefaultDelayedReveal<'a>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn default_visibility(
mut self,
value: impl Into<Option<ProfileDefaultVisibility<'a>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_default_visibility(
mut self,
value: Option<ProfileDefaultVisibility<'a>>,
) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn distance_unit(
mut self,
value: impl Into<Option<ProfileDistanceUnit<'a>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_distance_unit(
mut self,
value: Option<ProfileDistanceUnit<'a>>,
) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
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<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn language(mut self, value: impl Into<Option<ProfileLanguage<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_language(mut self, value: Option<ProfileLanguage<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn marker_color(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_marker_color(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
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<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::UpdatedAt: profile_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> ProfileBuilder<'a, profile_state::SetUpdatedAt<S>> {
self._fields.9 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::UpdatedAt: profile_state::IsSet,
{
pub fn build(self) -> Profile<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Profile<'a> {
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()
}
}