#[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, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
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};
use crate::community_lexicon::location::address::Address;
use crate::community_lexicon::location::fsq::Fsq;
use crate::community_lexicon::location::geo::Geo;
use crate::community_lexicon::location::hthree::Hthree;
use crate::community_lexicon::calendar::event;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Cancelled;
impl core::fmt::Display for Cancelled {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "cancelled")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Hybrid;
impl core::fmt::Display for Hybrid {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "hybrid")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Inperson;
impl core::fmt::Display for Inperson {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "inperson")
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Event<'a> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ends_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub locations: Option<Vec<EventLocationsItem<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub mode: Option<event::Mode<'a>>,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub starts_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub status: Option<event::Status<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub uris: Option<Vec<event::Uri<'a>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum EventLocationsItem<'a> {
#[serde(rename = "community.lexicon.calendar.event#uri")]
Uri(Box<event::Uri<'a>>),
#[serde(rename = "community.lexicon.location.address")]
Address(Box<Address<'a>>),
#[serde(rename = "community.lexicon.location.fsq")]
Fsq(Box<Fsq<'a>>),
#[serde(rename = "community.lexicon.location.geo")]
Geo(Box<Geo<'a>>),
#[serde(rename = "community.lexicon.location.hthree")]
Hthree(Box<Hthree<'a>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct EventGetRecordOutput<'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: Event<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Mode<'a> {
CommunityLexiconCalendarEventHybrid,
CommunityLexiconCalendarEventInperson,
CommunityLexiconCalendarEventVirtual,
Other(CowStr<'a>),
}
impl<'a> Mode<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::CommunityLexiconCalendarEventHybrid => {
"community.lexicon.calendar.event#hybrid"
}
Self::CommunityLexiconCalendarEventInperson => {
"community.lexicon.calendar.event#inperson"
}
Self::CommunityLexiconCalendarEventVirtual => {
"community.lexicon.calendar.event#virtual"
}
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for Mode<'a> {
fn from(s: &'a str) -> Self {
match s {
"community.lexicon.calendar.event#hybrid" => {
Self::CommunityLexiconCalendarEventHybrid
}
"community.lexicon.calendar.event#inperson" => {
Self::CommunityLexiconCalendarEventInperson
}
"community.lexicon.calendar.event#virtual" => {
Self::CommunityLexiconCalendarEventVirtual
}
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for Mode<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"community.lexicon.calendar.event#hybrid" => {
Self::CommunityLexiconCalendarEventHybrid
}
"community.lexicon.calendar.event#inperson" => {
Self::CommunityLexiconCalendarEventInperson
}
"community.lexicon.calendar.event#virtual" => {
Self::CommunityLexiconCalendarEventVirtual
}
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> AsRef<str> for Mode<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> core::fmt::Display for Mode<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> serde::Serialize for Mode<'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 Mode<'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 jacquard_common::IntoStatic for Mode<'_> {
type Output = Mode<'static>;
fn into_static(self) -> Self::Output {
match self {
Mode::CommunityLexiconCalendarEventHybrid => {
Mode::CommunityLexiconCalendarEventHybrid
}
Mode::CommunityLexiconCalendarEventInperson => {
Mode::CommunityLexiconCalendarEventInperson
}
Mode::CommunityLexiconCalendarEventVirtual => {
Mode::CommunityLexiconCalendarEventVirtual
}
Mode::Other(v) => Mode::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Planned;
impl core::fmt::Display for Planned {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "planned")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Postponed;
impl core::fmt::Display for Postponed {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "postponed")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Rescheduled;
impl core::fmt::Display for Rescheduled {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "rescheduled")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Scheduled;
impl core::fmt::Display for Scheduled {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "scheduled")
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Status<'a> {
CommunityLexiconCalendarEventCancelled,
CommunityLexiconCalendarEventPlanned,
CommunityLexiconCalendarEventPostponed,
CommunityLexiconCalendarEventRescheduled,
CommunityLexiconCalendarEventScheduled,
Other(CowStr<'a>),
}
impl<'a> Status<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::CommunityLexiconCalendarEventCancelled => {
"community.lexicon.calendar.event#cancelled"
}
Self::CommunityLexiconCalendarEventPlanned => {
"community.lexicon.calendar.event#planned"
}
Self::CommunityLexiconCalendarEventPostponed => {
"community.lexicon.calendar.event#postponed"
}
Self::CommunityLexiconCalendarEventRescheduled => {
"community.lexicon.calendar.event#rescheduled"
}
Self::CommunityLexiconCalendarEventScheduled => {
"community.lexicon.calendar.event#scheduled"
}
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for Status<'a> {
fn from(s: &'a str) -> Self {
match s {
"community.lexicon.calendar.event#cancelled" => {
Self::CommunityLexiconCalendarEventCancelled
}
"community.lexicon.calendar.event#planned" => {
Self::CommunityLexiconCalendarEventPlanned
}
"community.lexicon.calendar.event#postponed" => {
Self::CommunityLexiconCalendarEventPostponed
}
"community.lexicon.calendar.event#rescheduled" => {
Self::CommunityLexiconCalendarEventRescheduled
}
"community.lexicon.calendar.event#scheduled" => {
Self::CommunityLexiconCalendarEventScheduled
}
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for Status<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"community.lexicon.calendar.event#cancelled" => {
Self::CommunityLexiconCalendarEventCancelled
}
"community.lexicon.calendar.event#planned" => {
Self::CommunityLexiconCalendarEventPlanned
}
"community.lexicon.calendar.event#postponed" => {
Self::CommunityLexiconCalendarEventPostponed
}
"community.lexicon.calendar.event#rescheduled" => {
Self::CommunityLexiconCalendarEventRescheduled
}
"community.lexicon.calendar.event#scheduled" => {
Self::CommunityLexiconCalendarEventScheduled
}
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> AsRef<str> for Status<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> core::fmt::Display for Status<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> serde::Serialize for Status<'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 Status<'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 jacquard_common::IntoStatic for Status<'_> {
type Output = Status<'static>;
fn into_static(self) -> Self::Output {
match self {
Status::CommunityLexiconCalendarEventCancelled => {
Status::CommunityLexiconCalendarEventCancelled
}
Status::CommunityLexiconCalendarEventPlanned => {
Status::CommunityLexiconCalendarEventPlanned
}
Status::CommunityLexiconCalendarEventPostponed => {
Status::CommunityLexiconCalendarEventPostponed
}
Status::CommunityLexiconCalendarEventRescheduled => {
Status::CommunityLexiconCalendarEventRescheduled
}
Status::CommunityLexiconCalendarEventScheduled => {
Status::CommunityLexiconCalendarEventScheduled
}
Status::Other(v) => Status::Other(v.into_static()),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Uri<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub name: Option<CowStr<'a>>,
#[serde(borrow)]
pub uri: UriValue<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Virtual;
impl core::fmt::Display for Virtual {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "virtual")
}
}
impl<'a> Event<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, EventRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct EventRecord;
impl XrpcResp for EventRecord {
const NSID: &'static str = "community.lexicon.calendar.event";
const ENCODING: &'static str = "application/json";
type Output<'de> = EventGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<EventGetRecordOutput<'_>> for Event<'_> {
fn from(output: EventGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Event<'_> {
const NSID: &'static str = "community.lexicon.calendar.event";
type Record = EventRecord;
}
impl Collection for EventRecord {
const NSID: &'static str = "community.lexicon.calendar.event";
type Record = EventRecord;
}
impl<'a> LexiconSchema for Event<'a> {
fn nsid() -> &'static str {
"community.lexicon.calendar.event"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_community_lexicon_calendar_event()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Uri<'a> {
fn nsid() -> &'static str {
"community.lexicon.calendar.event"
}
fn def_name() -> &'static str {
"uri"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_community_lexicon_calendar_event()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod event_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 Name;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type CreatedAt = Unset;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Name = S::Name;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct created_at(());
}
}
pub struct EventBuilder<'a, S: event_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<Vec<EventLocationsItem<'a>>>,
Option<event::Mode<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<event::Status<'a>>,
Option<Vec<event::Uri<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Event<'a> {
pub fn new() -> EventBuilder<'a, event_state::Empty> {
EventBuilder::new()
}
}
impl<'a> EventBuilder<'a, event_state::Empty> {
pub fn new() -> Self {
EventBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> EventBuilder<'a, S>
where
S: event_state::State,
S::CreatedAt: event_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> EventBuilder<'a, event_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
EventBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn ends_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_ends_at(mut self, value: Option<Datetime>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn locations(
mut self,
value: impl Into<Option<Vec<EventLocationsItem<'a>>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_locations(
mut self,
value: Option<Vec<EventLocationsItem<'a>>>,
) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn mode(mut self, value: impl Into<Option<event::Mode<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_mode(mut self, value: Option<event::Mode<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> EventBuilder<'a, S>
where
S: event_state::State,
S::Name: event_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> EventBuilder<'a, event_state::SetName<S>> {
self._fields.5 = Option::Some(value.into());
EventBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn starts_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_starts_at(mut self, value: Option<Datetime>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn status(mut self, value: impl Into<Option<event::Status<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<event::Status<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: event_state::State> EventBuilder<'a, S> {
pub fn uris(mut self, value: impl Into<Option<Vec<event::Uri<'a>>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_uris(mut self, value: Option<Vec<event::Uri<'a>>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> EventBuilder<'a, S>
where
S: event_state::State,
S::Name: event_state::IsSet,
S::CreatedAt: event_state::IsSet,
{
pub fn build(self) -> Event<'a> {
Event {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
ends_at: self._fields.2,
locations: self._fields.3,
mode: self._fields.4,
name: self._fields.5.unwrap(),
starts_at: self._fields.6,
status: self._fields.7,
uris: self._fields.8,
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>,
>,
) -> Event<'a> {
Event {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
ends_at: self._fields.2,
locations: self._fields.3,
mode: self._fields.4,
name: self._fields.5.unwrap(),
starts_at: self._fields.6,
status: self._fields.7,
uris: self._fields.8,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_community_lexicon_calendar_event() -> 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("community.lexicon.calendar.event"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cancelled"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("hybrid"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("inperson"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static("A calendar event.")),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("createdAt"),
SmolStr::new_static("name")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Client-declared timestamp when the event was created.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The description of the event."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("endsAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Client-declared timestamp when the event ends.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("locations"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"The locations where the event takes place.",
),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("community.lexicon.calendar.event#uri"),
CowStr::new_static("community.lexicon.location.address"),
CowStr::new_static("community.lexicon.location.fsq"),
CowStr::new_static("community.lexicon.location.geo"),
CowStr::new_static("community.lexicon.location.hthree")
],
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mode"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"community.lexicon.calendar.event#mode",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The name of the event."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startsAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Client-declared timestamp when the event starts.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"community.lexicon.calendar.event#status",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uris"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("URIs associated with the event."),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"community.lexicon.calendar.event#uri",
),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mode"),
LexUserType::String(LexString {
description: Some(CowStr::new_static("The mode of the event.")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("planned"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("postponed"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("rescheduled"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("scheduled"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("status"),
LexUserType::String(LexString {
description: Some(CowStr::new_static("The status of the event.")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("A URI associated with the event."),
),
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The display name of the URI."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("virtual"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map
},
..Default::default()
}
}
pub mod uri_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct UriBuilder<'a, S: uri_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<UriValue<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Uri<'a> {
pub fn new() -> UriBuilder<'a, uri_state::Empty> {
UriBuilder::new()
}
}
impl<'a> UriBuilder<'a, uri_state::Empty> {
pub fn new() -> Self {
UriBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: uri_state::State> UriBuilder<'a, S> {
pub fn name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_name(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> UriBuilder<'a, S>
where
S: uri_state::State,
S::Uri: uri_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<'a>>,
) -> UriBuilder<'a, uri_state::SetUri<S>> {
self._fields.1 = Option::Some(value.into());
UriBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UriBuilder<'a, S>
where
S: uri_state::State,
S::Uri: uri_state::IsSet,
{
pub fn build(self) -> Uri<'a> {
Uri {
name: self._fields.0,
uri: self._fields.1.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>,
>,
) -> Uri<'a> {
Uri {
name: self._fields.0,
uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}