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