#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
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;
use crate::community_lexicon::calendar::event;
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;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[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")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "community.lexicon.calendar.event",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Event<S: BosStr = DefaultStr> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ends_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub locations: Option<Vec<EventLocationsItem<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mode: Option<event::Mode<S>>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub starts_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<event::Status<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub uris: Option<Vec<event::Uri<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 EventLocationsItem<S: BosStr = DefaultStr> {
#[serde(rename = "community.lexicon.calendar.event#uri")]
Uri(Box<event::Uri<S>>),
#[serde(rename = "community.lexicon.location.address")]
Address(Box<Address<S>>),
#[serde(rename = "community.lexicon.location.fsq")]
Fsq(Box<Fsq<S>>),
#[serde(rename = "community.lexicon.location.geo")]
Geo(Box<Geo<S>>),
#[serde(rename = "community.lexicon.location.hthree")]
Hthree(Box<Hthree<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct EventGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Event<S>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Mode<S: BosStr = DefaultStr> {
CommunityLexiconCalendarEventHybrid,
CommunityLexiconCalendarEventInperson,
CommunityLexiconCalendarEventVirtual,
Other(S),
}
impl<S: BosStr> Mode<S> {
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(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"community.lexicon.calendar.event#hybrid" => Self::CommunityLexiconCalendarEventHybrid,
"community.lexicon.calendar.event#inperson" => {
Self::CommunityLexiconCalendarEventInperson
}
"community.lexicon.calendar.event#virtual" => {
Self::CommunityLexiconCalendarEventVirtual
}
_ => Self::Other(s),
}
}
}
impl<S: BosStr> AsRef<str> for Mode<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> core::fmt::Display for Mode<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> Serialize for Mode<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 Mode<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> jacquard_common::IntoStatic for Mode<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = Mode<S::Output>;
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<S: BosStr = DefaultStr> {
CommunityLexiconCalendarEventCancelled,
CommunityLexiconCalendarEventPlanned,
CommunityLexiconCalendarEventPostponed,
CommunityLexiconCalendarEventRescheduled,
CommunityLexiconCalendarEventScheduled,
Other(S),
}
impl<S: BosStr> Status<S> {
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(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"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(s),
}
}
}
impl<S: BosStr> AsRef<str> for Status<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> core::fmt::Display for Status<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> Serialize for Status<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 Status<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> jacquard_common::IntoStatic for Status<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = Status<S::Output>;
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()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Uri<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<S>,
pub uri: UriValue<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, 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<S: BosStr> Event<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, EventRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[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<S: BosStr> = EventGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<EventGetRecordOutput<S>> for Event<S> {
fn from(output: EventGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Event<S> {
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<S: BosStr> LexiconSchema for Event<S> {
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<S: BosStr> LexiconSchema for Uri<S> {
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type CreatedAt;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Name = 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 Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type CreatedAt = St::CreatedAt;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct name(());
}
}
pub struct EventBuilder<S: BosStr, St: event_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<S>,
Option<Datetime>,
Option<Vec<EventLocationsItem<S>>>,
Option<event::Mode<S>>,
Option<S>,
Option<Datetime>,
Option<event::Status<S>>,
Option<Vec<event::Uri<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Event<S> {
pub fn new() -> EventBuilder<S, event_state::Empty> {
EventBuilder::new()
}
}
impl<S: BosStr> EventBuilder<S, event_state::Empty> {
pub fn new() -> Self {
EventBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EventBuilder<S, St>
where
St: event_state::State,
St::CreatedAt: event_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> EventBuilder<S, event_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
EventBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: event_state::State> EventBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: event_state::State> EventBuilder<S, St> {
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<S: BosStr, St: event_state::State> EventBuilder<S, St> {
pub fn locations(mut self, value: impl Into<Option<Vec<EventLocationsItem<S>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_locations(mut self, value: Option<Vec<EventLocationsItem<S>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: event_state::State> EventBuilder<S, St> {
pub fn mode(mut self, value: impl Into<Option<event::Mode<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_mode(mut self, value: Option<event::Mode<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> EventBuilder<S, St>
where
St: event_state::State,
St::Name: event_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> EventBuilder<S, event_state::SetName<St>> {
self._fields.5 = Option::Some(value.into());
EventBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: event_state::State> EventBuilder<S, St> {
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<S: BosStr, St: event_state::State> EventBuilder<S, St> {
pub fn status(mut self, value: impl Into<Option<event::Status<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<event::Status<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: event_state::State> EventBuilder<S, St> {
pub fn uris(mut self, value: impl Into<Option<Vec<event::Uri<S>>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_uris(mut self, value: Option<Vec<event::Uri<S>>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> EventBuilder<S, St>
where
St: event_state::State,
St::CreatedAt: event_state::IsSet,
St::Name: event_state::IsSet,
{
pub fn build(self) -> Event<S> {
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<SmolStr, Data<S>>) -> Event<S> {
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> {
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("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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct UriBuilder<S: BosStr, St: uri_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<UriValue<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Uri<S> {
pub fn new() -> UriBuilder<S, uri_state::Empty> {
UriBuilder::new()
}
}
impl<S: BosStr> UriBuilder<S, uri_state::Empty> {
pub fn new() -> Self {
UriBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: uri_state::State> UriBuilder<S, St> {
pub fn name(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_name(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> UriBuilder<S, St>
where
St: uri_state::State,
St::Uri: uri_state::IsUnset,
{
pub fn uri(mut self, value: impl Into<UriValue<S>>) -> UriBuilder<S, uri_state::SetUri<St>> {
self._fields.1 = Option::Some(value.into());
UriBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UriBuilder<S, St>
where
St: uri_state::State,
St::Uri: uri_state::IsSet,
{
pub fn build(self) -> Uri<S> {
Uri {
name: self._fields.0,
uri: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Uri<S> {
Uri {
name: self._fields.0,
uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}