#[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};
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};
use crate::com_atproto::repo::strong_ref::StrongRef;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Going;
impl core::fmt::Display for Going {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "going")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Interested;
impl core::fmt::Display for Interested {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "interested")
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Rsvp<'a> {
#[serde(borrow)]
pub status: RsvpStatus<'a>,
#[serde(borrow)]
pub subject: StrongRef<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RsvpStatus<'a> {
Interested,
Going,
Notgoing,
Other(CowStr<'a>),
}
impl<'a> RsvpStatus<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Interested => "community.lexicon.calendar.rsvp#interested",
Self::Going => "community.lexicon.calendar.rsvp#going",
Self::Notgoing => "community.lexicon.calendar.rsvp#notgoing",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for RsvpStatus<'a> {
fn from(s: &'a str) -> Self {
match s {
"community.lexicon.calendar.rsvp#interested" => Self::Interested,
"community.lexicon.calendar.rsvp#going" => Self::Going,
"community.lexicon.calendar.rsvp#notgoing" => Self::Notgoing,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for RsvpStatus<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"community.lexicon.calendar.rsvp#interested" => Self::Interested,
"community.lexicon.calendar.rsvp#going" => Self::Going,
"community.lexicon.calendar.rsvp#notgoing" => Self::Notgoing,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for RsvpStatus<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for RsvpStatus<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for RsvpStatus<'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 RsvpStatus<'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 RsvpStatus<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for RsvpStatus<'_> {
type Output = RsvpStatus<'static>;
fn into_static(self) -> Self::Output {
match self {
RsvpStatus::Interested => RsvpStatus::Interested,
RsvpStatus::Going => RsvpStatus::Going,
RsvpStatus::Notgoing => RsvpStatus::Notgoing,
RsvpStatus::Other(v) => RsvpStatus::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RsvpGetRecordOutput<'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: Rsvp<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Notgoing;
impl core::fmt::Display for Notgoing {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "notgoing")
}
}
impl<'a> Rsvp<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, RsvpRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RsvpRecord;
impl XrpcResp for RsvpRecord {
const NSID: &'static str = "community.lexicon.calendar.rsvp";
const ENCODING: &'static str = "application/json";
type Output<'de> = RsvpGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<RsvpGetRecordOutput<'_>> for Rsvp<'_> {
fn from(output: RsvpGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Rsvp<'_> {
const NSID: &'static str = "community.lexicon.calendar.rsvp";
type Record = RsvpRecord;
}
impl Collection for RsvpRecord {
const NSID: &'static str = "community.lexicon.calendar.rsvp";
type Record = RsvpRecord;
}
impl<'a> LexiconSchema for Rsvp<'a> {
fn nsid() -> &'static str {
"community.lexicon.calendar.rsvp"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_community_lexicon_calendar_rsvp()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod rsvp_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 Status;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Status = Unset;
type Subject = Unset;
}
pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStatus<S> {}
impl<S: State> State for SetStatus<S> {
type Status = Set<members::status>;
type Subject = S::Subject;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type Status = S::Status;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct status(());
pub struct subject(());
}
}
pub struct RsvpBuilder<'a, S: rsvp_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<RsvpStatus<'a>>, Option<StrongRef<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Rsvp<'a> {
pub fn new() -> RsvpBuilder<'a, rsvp_state::Empty> {
RsvpBuilder::new()
}
}
impl<'a> RsvpBuilder<'a, rsvp_state::Empty> {
pub fn new() -> Self {
RsvpBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> RsvpBuilder<'a, S>
where
S: rsvp_state::State,
S::Status: rsvp_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<RsvpStatus<'a>>,
) -> RsvpBuilder<'a, rsvp_state::SetStatus<S>> {
self._fields.0 = Option::Some(value.into());
RsvpBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RsvpBuilder<'a, S>
where
S: rsvp_state::State,
S::Subject: rsvp_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<StrongRef<'a>>,
) -> RsvpBuilder<'a, rsvp_state::SetSubject<S>> {
self._fields.1 = Option::Some(value.into());
RsvpBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RsvpBuilder<'a, S>
where
S: rsvp_state::State,
S::Status: rsvp_state::IsSet,
S::Subject: rsvp_state::IsSet,
{
pub fn build(self) -> Rsvp<'a> {
Rsvp {
status: self._fields.0.unwrap(),
subject: 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>,
>,
) -> Rsvp<'a> {
Rsvp {
status: self._fields.0.unwrap(),
subject: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_community_lexicon_calendar_rsvp() -> 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.rsvp"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("going"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("interested"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static("An RSVP for an event.")),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("subject"),
SmolStr::new_static("status")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notgoing"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map
},
..Default::default()
}
}