// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: org.atsui.Stack // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[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::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 Stack { /// Cross-axis alignment of children. Defaults to `"stretch"`. #[serde(skip_serializing_if = "Option::is_none")] #[serde(default = "_default_stack_align")] pub align: Option>, pub children: Data, /// Space between children. Defaults to `"medium"`. #[serde(skip_serializing_if = "Option::is_none")] #[serde(default = "_default_stack_gap")] pub gap: Option>, /// Whether this container has inset padding. The theme controls the amount. #[serde(skip_serializing_if = "Option::is_none")] pub inset: Option, /// Main-axis distribution of children. Defaults to `"start"`. #[serde(skip_serializing_if = "Option::is_none")] #[serde(default = "_default_stack_justify")] pub justify: Option>, /// Whether the container has an opaque background. #[serde(skip_serializing_if = "Option::is_none")] pub opaque: Option, /// Whether to show a visual separator between children. #[serde(skip_serializing_if = "Option::is_none")] pub separator: Option, /// Whether the container sticks to the top of the scroll area. #[serde(skip_serializing_if = "Option::is_none")] pub sticky: Option, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } /// Cross-axis alignment of children. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum StackAlign { Start, Center, End, Stretch, Other(S), } impl StackAlign { pub fn as_str(&self) -> &str { match self { Self::Start => "start", Self::Center => "center", Self::End => "end", Self::Stretch => "stretch", Self::Other(s) => s.as_ref(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "start" => Self::Start, "center" => Self::Center, "end" => Self::End, "stretch" => Self::Stretch, _ => Self::Other(s), } } } impl core::fmt::Display for StackAlign { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for StackAlign { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for StackAlign { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for StackAlign { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for StackAlign { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for StackAlign where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = StackAlign; fn into_static(self) -> Self::Output { match self { StackAlign::Start => StackAlign::Start, StackAlign::Center => StackAlign::Center, StackAlign::End => StackAlign::End, StackAlign::Stretch => StackAlign::Stretch, StackAlign::Other(v) => StackAlign::Other(v.into_static()), } } } /// Space between children. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum StackGap { None, Small, Medium, Large, Other(S), } impl StackGap { pub fn as_str(&self) -> &str { match self { Self::None => "none", Self::Small => "small", Self::Medium => "medium", Self::Large => "large", Self::Other(s) => s.as_ref(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "none" => Self::None, "small" => Self::Small, "medium" => Self::Medium, "large" => Self::Large, _ => Self::Other(s), } } } impl core::fmt::Display for StackGap { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for StackGap { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for StackGap { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for StackGap { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for StackGap { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for StackGap where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = StackGap; fn into_static(self) -> Self::Output { match self { StackGap::None => StackGap::None, StackGap::Small => StackGap::Small, StackGap::Medium => StackGap::Medium, StackGap::Large => StackGap::Large, StackGap::Other(v) => StackGap::Other(v.into_static()), } } } /// Main-axis distribution of children. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum StackJustify { Start, Center, End, Between, Other(S), } impl StackJustify { pub fn as_str(&self) -> &str { match self { Self::Start => "start", Self::Center => "center", Self::End => "end", Self::Between => "between", Self::Other(s) => s.as_ref(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "start" => Self::Start, "center" => Self::Center, "end" => Self::End, "between" => Self::Between, _ => Self::Other(s), } } } impl core::fmt::Display for StackJustify { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for StackJustify { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for StackJustify { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for StackJustify { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for StackJustify { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for StackJustify where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = StackJustify; fn into_static(self) -> Self::Output { match self { StackJustify::Start => StackJustify::Start, StackJustify::Center => StackJustify::Center, StackJustify::End => StackJustify::End, StackJustify::Between => StackJustify::Between, StackJustify::Other(v) => StackJustify::Other(v.into_static()), } } } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct StackOutput { #[serde(flatten)] pub value: Response, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } /** Response marker for the `org.atsui.Stack` procedure. Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output`, which is `StackOutput` for this endpoint.*/ pub struct StackResponse; impl jacquard_common::xrpc::XrpcResp for StackResponse { const NSID: &'static str = "org.atsui.Stack"; const ENCODING: &'static str = "application/json"; type Output = StackOutput; type Err = jacquard_common::xrpc::GenericError; } impl jacquard_common::xrpc::XrpcRequest for Stack { const NSID: &'static str = "org.atsui.Stack"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure("application/json"); type Response = StackResponse; } /** Endpoint marker for the `org.atsui.Stack` procedure. Path: `/xrpc/org.atsui.Stack`. The request payload type is `Stack`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/ pub struct StackRequest; impl jacquard_common::xrpc::XrpcEndpoint for StackRequest { const PATH: &'static str = "/xrpc/org.atsui.Stack"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure("application/json"); type Request = Stack; type Response = StackResponse; } fn _default_stack_align() -> ::core::option::Option> { Some(>::from_value(S::from_static("stretch"))) } fn _default_stack_gap() -> ::core::option::Option> { Some(>::from_value(S::from_static("medium"))) } fn _default_stack_justify() -> ::core::option::Option> { Some(>::from_value(S::from_static("start"))) } pub mod stack_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Children; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Children = Unset; } ///State transition - sets the `children` field to Set pub struct SetChildren(PhantomData St>); impl sealed::Sealed for SetChildren {} impl State for SetChildren { type Children = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `children` field pub struct children(()); } } /// Builder for constructing an instance of this type. pub struct StackBuilder { _state: PhantomData St>, _fields: ( Option>, Option>, Option>, Option, Option>, Option, Option, Option, ), _type: PhantomData S>, } impl Stack { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> StackBuilder { StackBuilder::new() } } impl Stack { /// Create a new builder for this type pub fn builder() -> StackBuilder { StackBuilder::builder() } } impl StackBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { StackBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None), _type: PhantomData, } } } impl StackBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { StackBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None), _type: PhantomData, } } } impl StackBuilder { /// Set the `align` field (optional) pub fn align(mut self, value: impl Into>>) -> Self { self._fields.0 = value.into(); self } /// Set the `align` field to an Option value (optional) pub fn maybe_align(mut self, value: Option>) -> Self { self._fields.0 = value; self } } impl StackBuilder where St: stack_state::State, St::Children: stack_state::IsUnset, { /// Set the `children` field (required) pub fn children( mut self, value: impl Into>, ) -> StackBuilder, S> { self._fields.1 = Option::Some(value.into()); StackBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl StackBuilder { /// Set the `gap` field (optional) pub fn gap(mut self, value: impl Into>>) -> Self { self._fields.2 = value.into(); self } /// Set the `gap` field to an Option value (optional) pub fn maybe_gap(mut self, value: Option>) -> Self { self._fields.2 = value; self } } impl StackBuilder { /// Set the `inset` field (optional) pub fn inset(mut self, value: impl Into>) -> Self { self._fields.3 = value.into(); self } /// Set the `inset` field to an Option value (optional) pub fn maybe_inset(mut self, value: Option) -> Self { self._fields.3 = value; self } } impl StackBuilder { /// Set the `justify` field (optional) pub fn justify(mut self, value: impl Into>>) -> Self { self._fields.4 = value.into(); self } /// Set the `justify` field to an Option value (optional) pub fn maybe_justify(mut self, value: Option>) -> Self { self._fields.4 = value; self } } impl StackBuilder { /// Set the `opaque` field (optional) pub fn opaque(mut self, value: impl Into>) -> Self { self._fields.5 = value.into(); self } /// Set the `opaque` field to an Option value (optional) pub fn maybe_opaque(mut self, value: Option) -> Self { self._fields.5 = value; self } } impl StackBuilder { /// Set the `separator` field (optional) pub fn separator(mut self, value: impl Into>) -> Self { self._fields.6 = value.into(); self } /// Set the `separator` field to an Option value (optional) pub fn maybe_separator(mut self, value: Option) -> Self { self._fields.6 = value; self } } impl StackBuilder { /// Set the `sticky` field (optional) pub fn sticky(mut self, value: impl Into>) -> Self { self._fields.7 = value.into(); self } /// Set the `sticky` field to an Option value (optional) pub fn maybe_sticky(mut self, value: Option) -> Self { self._fields.7 = value; self } } impl StackBuilder where St: stack_state::State, St::Children: stack_state::IsSet, { /// Build the final struct. pub fn build(self) -> Stack { Stack { align: self._fields.0, children: self._fields.1.unwrap(), gap: self._fields.2, inset: self._fields.3, justify: self._fields.4, opaque: self._fields.5, separator: self._fields.6, sticky: self._fields.7, extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> Stack { Stack { align: self._fields.0, children: self._fields.1.unwrap(), gap: self._fields.2, inset: self._fields.3, justify: self._fields.4, opaque: self._fields.5, separator: self._fields.6, sticky: self._fields.7, extra_data: Some(extra_data), } } }