#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use serde::{Serialize, Deserialize};
use crate::com_atprotofans::hydrated_profile::HydratedProfile;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ValidateSupporter<S: BosStr = DefaultStr> {
pub signer: Did<S>,
pub subject: Did<S>,
pub supporter: Did<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ValidateSupporterOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub profile: Option<HydratedProfile<S>>,
pub valid: bool,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum ValidateSupporterError {
#[serde(rename = "InvalidRequest")]
InvalidRequest(Option<SmolStr>),
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for ValidateSupporterError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::InvalidRequest(msg) => {
write!(f, "InvalidRequest")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
pub struct ValidateSupporterResponse;
impl jacquard_common::xrpc::XrpcResp for ValidateSupporterResponse {
const NSID: &'static str = "com.atprotofans.validateSupporter";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ValidateSupporterOutput<S>;
type Err = ValidateSupporterError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ValidateSupporter<S> {
const NSID: &'static str = "com.atprotofans.validateSupporter";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ValidateSupporterResponse;
}
pub struct ValidateSupporterRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ValidateSupporterRequest {
const PATH: &'static str = "/xrpc/com.atprotofans.validateSupporter";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = ValidateSupporter<S>;
type Response = ValidateSupporterResponse;
}
pub mod validate_supporter_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 Signer;
type Supporter;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Signer = Unset;
type Supporter = Unset;
type Subject = Unset;
}
pub struct SetSigner<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSigner<St> {}
impl<St: State> State for SetSigner<St> {
type Signer = Set<members::signer>;
type Supporter = St::Supporter;
type Subject = St::Subject;
}
pub struct SetSupporter<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSupporter<St> {}
impl<St: State> State for SetSupporter<St> {
type Signer = St::Signer;
type Supporter = Set<members::supporter>;
type Subject = St::Subject;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Signer = St::Signer;
type Supporter = St::Supporter;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct signer(());
pub struct supporter(());
pub struct subject(());
}
}
pub struct ValidateSupporterBuilder<S: BosStr, St: validate_supporter_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>, Option<Did<S>>, Option<Did<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ValidateSupporter<S> {
pub fn new() -> ValidateSupporterBuilder<S, validate_supporter_state::Empty> {
ValidateSupporterBuilder::new()
}
}
impl<S: BosStr> ValidateSupporterBuilder<S, validate_supporter_state::Empty> {
pub fn new() -> Self {
ValidateSupporterBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ValidateSupporterBuilder<S, St>
where
St: validate_supporter_state::State,
St::Signer: validate_supporter_state::IsUnset,
{
pub fn signer(
mut self,
value: impl Into<Did<S>>,
) -> ValidateSupporterBuilder<S, validate_supporter_state::SetSigner<St>> {
self._fields.0 = Option::Some(value.into());
ValidateSupporterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ValidateSupporterBuilder<S, St>
where
St: validate_supporter_state::State,
St::Subject: validate_supporter_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<Did<S>>,
) -> ValidateSupporterBuilder<S, validate_supporter_state::SetSubject<St>> {
self._fields.1 = Option::Some(value.into());
ValidateSupporterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ValidateSupporterBuilder<S, St>
where
St: validate_supporter_state::State,
St::Supporter: validate_supporter_state::IsUnset,
{
pub fn supporter(
mut self,
value: impl Into<Did<S>>,
) -> ValidateSupporterBuilder<S, validate_supporter_state::SetSupporter<St>> {
self._fields.2 = Option::Some(value.into());
ValidateSupporterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ValidateSupporterBuilder<S, St>
where
St: validate_supporter_state::State,
St::Signer: validate_supporter_state::IsSet,
St::Supporter: validate_supporter_state::IsSet,
St::Subject: validate_supporter_state::IsSet,
{
pub fn build(self) -> ValidateSupporter<S> {
ValidateSupporter {
signer: self._fields.0.unwrap(),
subject: self._fields.1.unwrap(),
supporter: self._fields.2.unwrap(),
}
}
}