#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::{Did, AtUri};
use jacquard_derive::{IntoStatic, lexicon, open_union};
use serde::{Serialize, Deserialize};
use crate::community_lexicon::calendar::rsvp::Rsvp;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetRsvp<'a> {
#[serde(borrow)]
pub event: AtUri<'a>,
#[serde(borrow)]
pub identity: Did<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetRsvpOutput<'a> {
#[serde(borrow)]
pub cid: CowStr<'a>,
#[serde(borrow)]
pub record: Rsvp<'a>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
#[open_union]
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic,
IntoStatic
)]
#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetRsvpError<'a> {
#[serde(rename = "NotFound")]
NotFound(Option<CowStr<'a>>),
}
impl core::fmt::Display for GetRsvpError<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::NotFound(msg) => {
write!(f, "NotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
}
}
}
pub struct GetRsvpResponse;
impl jacquard_common::xrpc::XrpcResp for GetRsvpResponse {
const NSID: &'static str = "community.lexicon.calendar.getRSVP";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetRsvpOutput<'de>;
type Err<'de> = GetRsvpError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetRsvp<'a> {
const NSID: &'static str = "community.lexicon.calendar.getRSVP";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetRsvpResponse;
}
pub struct GetRsvpRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetRsvpRequest {
const PATH: &'static str = "/xrpc/community.lexicon.calendar.getRSVP";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetRsvp<'de>;
type Response = GetRsvpResponse;
}
pub mod get_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 Identity;
type Event;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Identity = Unset;
type Event = Unset;
}
pub struct SetIdentity<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIdentity<S> {}
impl<S: State> State for SetIdentity<S> {
type Identity = Set<members::identity>;
type Event = S::Event;
}
pub struct SetEvent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEvent<S> {}
impl<S: State> State for SetEvent<S> {
type Identity = S::Identity;
type Event = Set<members::event>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct identity(());
pub struct event(());
}
}
pub struct GetRsvpBuilder<'a, S: get_rsvp_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<AtUri<'a>>, Option<Did<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetRsvp<'a> {
pub fn new() -> GetRsvpBuilder<'a, get_rsvp_state::Empty> {
GetRsvpBuilder::new()
}
}
impl<'a> GetRsvpBuilder<'a, get_rsvp_state::Empty> {
pub fn new() -> Self {
GetRsvpBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetRsvpBuilder<'a, S>
where
S: get_rsvp_state::State,
S::Event: get_rsvp_state::IsUnset,
{
pub fn event(
mut self,
value: impl Into<AtUri<'a>>,
) -> GetRsvpBuilder<'a, get_rsvp_state::SetEvent<S>> {
self._fields.0 = Option::Some(value.into());
GetRsvpBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetRsvpBuilder<'a, S>
where
S: get_rsvp_state::State,
S::Identity: get_rsvp_state::IsUnset,
{
pub fn identity(
mut self,
value: impl Into<Did<'a>>,
) -> GetRsvpBuilder<'a, get_rsvp_state::SetIdentity<S>> {
self._fields.1 = Option::Some(value.into());
GetRsvpBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetRsvpBuilder<'a, S>
where
S: get_rsvp_state::State,
S::Identity: get_rsvp_state::IsSet,
S::Event: get_rsvp_state::IsSet,
{
pub fn build(self) -> GetRsvp<'a> {
GetRsvp {
event: self._fields.0.unwrap(),
identity: self._fields.1.unwrap(),
}
}
}