#[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, open_union};
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 = "events.smokesignal.lfg",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Lfg<S: BosStr = DefaultStr> {
pub active: bool,
pub created_at: Datetime,
pub ends_at: Datetime,
pub location: LfgLocation<S>,
pub starts_at: Datetime,
pub tags: Vec<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum LfgLocation<S: BosStr = DefaultStr> {}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LfgGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Lfg<S>,
}
impl<S: BosStr> Lfg<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, LfgRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LfgRecord;
impl XrpcResp for LfgRecord {
const NSID: &'static str = "events.smokesignal.lfg";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = LfgGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<LfgGetRecordOutput<S>> for Lfg<S> {
fn from(output: LfgGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Lfg<S> {
const NSID: &'static str = "events.smokesignal.lfg";
type Record = LfgRecord;
}
impl Collection for LfgRecord {
const NSID: &'static str = "events.smokesignal.lfg";
type Record = LfgRecord;
}
impl<S: BosStr> LexiconSchema for Lfg<S> {
fn nsid() -> &'static str {
"events.smokesignal.lfg"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_events_smokesignal_lfg()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.tags;
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("tags"),
max: 10usize,
actual: value.len(),
});
}
}
{
let value = &self.tags;
#[allow(unused_comparisons)]
if value.len() < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("tags"),
min: 1usize,
actual: value.len(),
});
}
}
Ok(())
}
}
pub mod lfg_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 Active;
type StartsAt;
type EndsAt;
type Location;
type Tags;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Active = Unset;
type StartsAt = Unset;
type EndsAt = Unset;
type Location = Unset;
type Tags = Unset;
type CreatedAt = Unset;
}
pub struct SetActive<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetActive<St> {}
impl<St: State> State for SetActive<St> {
type Active = Set<members::active>;
type StartsAt = St::StartsAt;
type EndsAt = St::EndsAt;
type Location = St::Location;
type Tags = St::Tags;
type CreatedAt = St::CreatedAt;
}
pub struct SetStartsAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStartsAt<St> {}
impl<St: State> State for SetStartsAt<St> {
type Active = St::Active;
type StartsAt = Set<members::starts_at>;
type EndsAt = St::EndsAt;
type Location = St::Location;
type Tags = St::Tags;
type CreatedAt = St::CreatedAt;
}
pub struct SetEndsAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEndsAt<St> {}
impl<St: State> State for SetEndsAt<St> {
type Active = St::Active;
type StartsAt = St::StartsAt;
type EndsAt = Set<members::ends_at>;
type Location = St::Location;
type Tags = St::Tags;
type CreatedAt = St::CreatedAt;
}
pub struct SetLocation<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLocation<St> {}
impl<St: State> State for SetLocation<St> {
type Active = St::Active;
type StartsAt = St::StartsAt;
type EndsAt = St::EndsAt;
type Location = Set<members::location>;
type Tags = St::Tags;
type CreatedAt = St::CreatedAt;
}
pub struct SetTags<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTags<St> {}
impl<St: State> State for SetTags<St> {
type Active = St::Active;
type StartsAt = St::StartsAt;
type EndsAt = St::EndsAt;
type Location = St::Location;
type Tags = Set<members::tags>;
type CreatedAt = St::CreatedAt;
}
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 Active = St::Active;
type StartsAt = St::StartsAt;
type EndsAt = St::EndsAt;
type Location = St::Location;
type Tags = St::Tags;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct active(());
pub struct starts_at(());
pub struct ends_at(());
pub struct location(());
pub struct tags(());
pub struct created_at(());
}
}
pub struct LfgBuilder<S: BosStr, St: lfg_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<bool>,
Option<Datetime>,
Option<Datetime>,
Option<LfgLocation<S>>,
Option<Datetime>,
Option<Vec<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Lfg<S> {
pub fn new() -> LfgBuilder<S, lfg_state::Empty> {
LfgBuilder::new()
}
}
impl<S: BosStr> LfgBuilder<S, lfg_state::Empty> {
pub fn new() -> Self {
LfgBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::Active: lfg_state::IsUnset,
{
pub fn active(
mut self,
value: impl Into<bool>,
) -> LfgBuilder<S, lfg_state::SetActive<St>> {
self._fields.0 = Option::Some(value.into());
LfgBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::CreatedAt: lfg_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> LfgBuilder<S, lfg_state::SetCreatedAt<St>> {
self._fields.1 = Option::Some(value.into());
LfgBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::EndsAt: lfg_state::IsUnset,
{
pub fn ends_at(
mut self,
value: impl Into<Datetime>,
) -> LfgBuilder<S, lfg_state::SetEndsAt<St>> {
self._fields.2 = Option::Some(value.into());
LfgBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::Location: lfg_state::IsUnset,
{
pub fn location(
mut self,
value: impl Into<LfgLocation<S>>,
) -> LfgBuilder<S, lfg_state::SetLocation<St>> {
self._fields.3 = Option::Some(value.into());
LfgBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::StartsAt: lfg_state::IsUnset,
{
pub fn starts_at(
mut self,
value: impl Into<Datetime>,
) -> LfgBuilder<S, lfg_state::SetStartsAt<St>> {
self._fields.4 = Option::Some(value.into());
LfgBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::Tags: lfg_state::IsUnset,
{
pub fn tags(
mut self,
value: impl Into<Vec<S>>,
) -> LfgBuilder<S, lfg_state::SetTags<St>> {
self._fields.5 = Option::Some(value.into());
LfgBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LfgBuilder<S, St>
where
St: lfg_state::State,
St::Active: lfg_state::IsSet,
St::StartsAt: lfg_state::IsSet,
St::EndsAt: lfg_state::IsSet,
St::Location: lfg_state::IsSet,
St::Tags: lfg_state::IsSet,
St::CreatedAt: lfg_state::IsSet,
{
pub fn build(self) -> Lfg<S> {
Lfg {
active: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
ends_at: self._fields.2.unwrap(),
location: self._fields.3.unwrap(),
starts_at: self._fields.4.unwrap(),
tags: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Lfg<S> {
Lfg {
active: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
ends_at: self._fields.2.unwrap(),
location: self._fields.3.unwrap(),
starts_at: self._fields.4.unwrap(),
tags: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_events_smokesignal_lfg() -> 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("events.smokesignal.lfg"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A Looking For Group record that broadcasts interest in finding activity partners within a geographic area.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("location"),
SmolStr::new_static("tags"),
SmolStr::new_static("startsAt"),
SmolStr::new_static("endsAt"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("active")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("active"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Record creation timestamp."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("endsAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the LFG expires and is no longer visible.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("location"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"The geographic location for activity partner matching.",
),
),
refs: vec![
CowStr::new_static("community.lexicon.location#geo"),
CowStr::new_static("community.lexicon.location#hthree")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startsAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the LFG becomes active."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tags"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Interest tags for matching with events and other users.",
),
),
items: LexArrayItem::String(LexString {
max_length: Some(64usize),
max_graphemes: Some(64usize),
..Default::default()
}),
min_length: Some(1usize),
max_length: Some(10usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}