#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::at_inlay::Element;
use crate::at_inlay::Response;
use crate::org_atsui::tabs;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Tabs<'a> {
#[serde(borrow)]
pub items: Vec<tabs::Tab<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TabsOutput<'a> {
#[serde(flatten)]
#[serde(borrow)]
pub value: Response<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Tab<'a> {
#[serde(borrow)]
pub content: Element<'a>,
#[serde(borrow)]
pub key: CowStr<'a>,
#[serde(borrow)]
pub label: CowStr<'a>,
}
pub struct TabsResponse;
impl jacquard_common::xrpc::XrpcResp for TabsResponse {
const NSID: &'static str = "org.atsui.Tabs";
const ENCODING: &'static str = "application/json";
type Output<'de> = TabsOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for Tabs<'a> {
const NSID: &'static str = "org.atsui.Tabs";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = TabsResponse;
}
pub struct TabsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for TabsRequest {
const PATH: &'static str = "/xrpc/org.atsui.Tabs";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = Tabs<'de>;
type Response = TabsResponse;
}
impl<'a> LexiconSchema for Tab<'a> {
fn nsid() -> &'static str {
"org.atsui.Tabs"
}
fn def_name() -> &'static str {
"tab"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_atsui_Tabs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.key;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("key"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.label;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("label"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod tabs_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 Items;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Items = Unset;
}
pub struct SetItems<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetItems<S> {}
impl<S: State> State for SetItems<S> {
type Items = Set<members::items>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct items(());
}
}
pub struct TabsBuilder<'a, S: tabs_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<tabs::Tab<'a>>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Tabs<'a> {
pub fn new() -> TabsBuilder<'a, tabs_state::Empty> {
TabsBuilder::new()
}
}
impl<'a> TabsBuilder<'a, tabs_state::Empty> {
pub fn new() -> Self {
TabsBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> TabsBuilder<'a, S>
where
S: tabs_state::State,
S::Items: tabs_state::IsUnset,
{
pub fn items(
mut self,
value: impl Into<Vec<tabs::Tab<'a>>>,
) -> TabsBuilder<'a, tabs_state::SetItems<S>> {
self._fields.0 = Option::Some(value.into());
TabsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TabsBuilder<'a, S>
where
S: tabs_state::State,
S::Items: tabs_state::IsSet,
{
pub fn build(self) -> Tabs<'a> {
Tabs {
items: 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>,
>,
) -> Tabs<'a> {
Tabs {
items: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod tab_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 Content;
type Key;
type Label;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Content = Unset;
type Key = Unset;
type Label = Unset;
}
pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContent<S> {}
impl<S: State> State for SetContent<S> {
type Content = Set<members::content>;
type Key = S::Key;
type Label = S::Label;
}
pub struct SetKey<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetKey<S> {}
impl<S: State> State for SetKey<S> {
type Content = S::Content;
type Key = Set<members::key>;
type Label = S::Label;
}
pub struct SetLabel<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLabel<S> {}
impl<S: State> State for SetLabel<S> {
type Content = S::Content;
type Key = S::Key;
type Label = Set<members::label>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content(());
pub struct key(());
pub struct label(());
}
}
pub struct TabBuilder<'a, S: tab_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Element<'a>>, Option<CowStr<'a>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Tab<'a> {
pub fn new() -> TabBuilder<'a, tab_state::Empty> {
TabBuilder::new()
}
}
impl<'a> TabBuilder<'a, tab_state::Empty> {
pub fn new() -> Self {
TabBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> TabBuilder<'a, S>
where
S: tab_state::State,
S::Content: tab_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<Element<'a>>,
) -> TabBuilder<'a, tab_state::SetContent<S>> {
self._fields.0 = Option::Some(value.into());
TabBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TabBuilder<'a, S>
where
S: tab_state::State,
S::Key: tab_state::IsUnset,
{
pub fn key(
mut self,
value: impl Into<CowStr<'a>>,
) -> TabBuilder<'a, tab_state::SetKey<S>> {
self._fields.1 = Option::Some(value.into());
TabBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TabBuilder<'a, S>
where
S: tab_state::State,
S::Label: tab_state::IsUnset,
{
pub fn label(
mut self,
value: impl Into<CowStr<'a>>,
) -> TabBuilder<'a, tab_state::SetLabel<S>> {
self._fields.2 = Option::Some(value.into());
TabBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TabBuilder<'a, S>
where
S: tab_state::State,
S::Content: tab_state::IsSet,
S::Key: tab_state::IsSet,
S::Label: tab_state::IsSet,
{
pub fn build(self) -> Tab<'a> {
Tab {
content: self._fields.0.unwrap(),
key: self._fields.1.unwrap(),
label: self._fields.2.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>,
>,
) -> Tab<'a> {
Tab {
content: self._fields.0.unwrap(),
key: self._fields.1.unwrap(),
label: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_atsui_Tabs() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("org.atsui.Tabs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(
LexXrpcBodySchema::Object(LexObject {
required: Some(vec![SmolStr::new_static("items")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("items"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static("Tabs to display.")),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#tab"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tab"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("key"), SmolStr::new_static("label"),
SmolStr::new_static("content")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("at.inlay.defs#element"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("key"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Stable key that identifies the tab among its siblings.",
),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("label"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Display label for the tab."),
),
max_length: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}