#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use crate::at_inlay::Response;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, 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 Cover<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<Did<S>>,
pub src: Data<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CoverOutput<S: BosStr = DefaultStr> {
#[serde(flatten)]
pub value: Response<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct CoverResponse;
impl jacquard_common::xrpc::XrpcResp for CoverResponse {
const NSID: &'static str = "org.atsui.Cover";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CoverOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for Cover<S> {
const NSID: &'static str = "org.atsui.Cover";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = CoverResponse;
}
pub struct CoverRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CoverRequest {
const PATH: &'static str = "/xrpc/org.atsui.Cover";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = Cover<S>;
type Response = CoverResponse;
}
pub mod cover_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 Src;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Src = Unset;
}
pub struct SetSrc<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSrc<St> {}
impl<St: State> State for SetSrc<St> {
type Src = Set<members::src>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct src(());
}
}
pub struct CoverBuilder<S: BosStr, St: cover_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>, Option<Data<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Cover<S> {
pub fn new() -> CoverBuilder<S, cover_state::Empty> {
CoverBuilder::new()
}
}
impl<S: BosStr> CoverBuilder<S, cover_state::Empty> {
pub fn new() -> Self {
CoverBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: cover_state::State> CoverBuilder<S, St> {
pub fn did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_did(mut self, value: Option<Did<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> CoverBuilder<S, St>
where
St: cover_state::State,
St::Src: cover_state::IsUnset,
{
pub fn src(mut self, value: impl Into<Data<S>>) -> CoverBuilder<S, cover_state::SetSrc<St>> {
self._fields.1 = Option::Some(value.into());
CoverBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CoverBuilder<S, St>
where
St: cover_state::State,
St::Src: cover_state::IsSet,
{
pub fn build(self) -> Cover<S> {
Cover {
did: self._fields.0,
src: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Cover<S> {
Cover {
did: self._fields.0,
src: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}