#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use crate::app_rocksky::song::SongViewDetailed;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::IntoStatic;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct MatchSong<S: BosStr = DefaultStr> {
pub artist: S,
pub title: S,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct MatchSongOutput<S: BosStr = DefaultStr> {
#[serde(flatten)]
pub value: SongViewDetailed<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct MatchSongResponse;
impl jacquard_common::xrpc::XrpcResp for MatchSongResponse {
const NSID: &'static str = "app.rocksky.song.matchSong";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = MatchSongOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for MatchSong<S> {
const NSID: &'static str = "app.rocksky.song.matchSong";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = MatchSongResponse;
}
pub struct MatchSongRequest;
impl jacquard_common::xrpc::XrpcEndpoint for MatchSongRequest {
const PATH: &'static str = "/xrpc/app.rocksky.song.matchSong";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = MatchSong<S>;
type Response = MatchSongResponse;
}
pub mod match_song_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 Title;
type Artist;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Title = Unset;
type Artist = Unset;
}
pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTitle<St> {}
impl<St: State> State for SetTitle<St> {
type Title = Set<members::title>;
type Artist = St::Artist;
}
pub struct SetArtist<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetArtist<St> {}
impl<St: State> State for SetArtist<St> {
type Title = St::Title;
type Artist = Set<members::artist>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct title(());
pub struct artist(());
}
}
pub struct MatchSongBuilder<S: BosStr, St: match_song_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> MatchSong<S> {
pub fn new() -> MatchSongBuilder<S, match_song_state::Empty> {
MatchSongBuilder::new()
}
}
impl<S: BosStr> MatchSongBuilder<S, match_song_state::Empty> {
pub fn new() -> Self {
MatchSongBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MatchSongBuilder<S, St>
where
St: match_song_state::State,
St::Artist: match_song_state::IsUnset,
{
pub fn artist(
mut self,
value: impl Into<S>,
) -> MatchSongBuilder<S, match_song_state::SetArtist<St>> {
self._fields.0 = Option::Some(value.into());
MatchSongBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MatchSongBuilder<S, St>
where
St: match_song_state::State,
St::Title: match_song_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<S>,
) -> MatchSongBuilder<S, match_song_state::SetTitle<St>> {
self._fields.1 = Option::Some(value.into());
MatchSongBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MatchSongBuilder<S, St>
where
St: match_song_state::State,
St::Title: match_song_state::IsSet,
St::Artist: match_song_state::IsSet,
{
pub fn build(self) -> MatchSong<S> {
MatchSong {
artist: self._fields.0.unwrap(),
title: self._fields.1.unwrap(),
}
}
}