#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::AtUri;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ToggleLike<'a> {
#[serde(borrow)]
pub subject: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ToggleLikeOutput<'a> {
#[serde(borrow)]
pub action: ToggleLikeOutputAction<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub uri: Option<AtUri<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ToggleLikeOutputAction<'a> {
Liked,
Unliked,
Other(CowStr<'a>),
}
impl<'a> ToggleLikeOutputAction<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Liked => "liked",
Self::Unliked => "unliked",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for ToggleLikeOutputAction<'a> {
fn from(s: &'a str) -> Self {
match s {
"liked" => Self::Liked,
"unliked" => Self::Unliked,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ToggleLikeOutputAction<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"liked" => Self::Liked,
"unliked" => Self::Unliked,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ToggleLikeOutputAction<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ToggleLikeOutputAction<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ToggleLikeOutputAction<'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 ToggleLikeOutputAction<'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 ToggleLikeOutputAction<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ToggleLikeOutputAction<'_> {
type Output = ToggleLikeOutputAction<'static>;
fn into_static(self) -> Self::Output {
match self {
ToggleLikeOutputAction::Liked => ToggleLikeOutputAction::Liked,
ToggleLikeOutputAction::Unliked => ToggleLikeOutputAction::Unliked,
ToggleLikeOutputAction::Other(v) => {
ToggleLikeOutputAction::Other(v.into_static())
}
}
}
}
pub struct ToggleLikeResponse;
impl jacquard_common::xrpc::XrpcResp for ToggleLikeResponse {
const NSID: &'static str = "games.gamesgamesgamesgames.graph.toggleLike";
const ENCODING: &'static str = "application/json";
type Output<'de> = ToggleLikeOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for ToggleLike<'a> {
const NSID: &'static str = "games.gamesgamesgamesgames.graph.toggleLike";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = ToggleLikeResponse;
}
pub struct ToggleLikeRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ToggleLikeRequest {
const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.graph.toggleLike";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = ToggleLike<'de>;
type Response = ToggleLikeResponse;
}
pub mod toggle_like_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 Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
}
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 Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
}
}
pub struct ToggleLikeBuilder<'a, S: toggle_like_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<AtUri<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ToggleLike<'a> {
pub fn new() -> ToggleLikeBuilder<'a, toggle_like_state::Empty> {
ToggleLikeBuilder::new()
}
}
impl<'a> ToggleLikeBuilder<'a, toggle_like_state::Empty> {
pub fn new() -> Self {
ToggleLikeBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ToggleLikeBuilder<'a, S>
where
S: toggle_like_state::State,
S::Subject: toggle_like_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<AtUri<'a>>,
) -> ToggleLikeBuilder<'a, toggle_like_state::SetSubject<S>> {
self._fields.0 = Option::Some(value.into());
ToggleLikeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ToggleLikeBuilder<'a, S>
where
S: toggle_like_state::State,
S::Subject: toggle_like_state::IsSet,
{
pub fn build(self) -> ToggleLike<'a> {
ToggleLike {
subject: self._fields.0.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>,
>,
) -> ToggleLike<'a> {
ToggleLike {
subject: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}