#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Row<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub align: std::option::Option<RowAlign<'a>>,
#[serde(borrow)]
pub children: jacquard_common::types::value::Data<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub gap: std::option::Option<RowGap<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub inset: std::option::Option<bool>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub justify: std::option::Option<RowJustify<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub opaque: std::option::Option<bool>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub sticky: std::option::Option<bool>,
}
pub mod row_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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetChildren<S> {}
impl<S: State> State for SetChildren<S> {
type Children = Set<members::children>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct children(());
}
}
pub struct RowBuilder<'a, S: row_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<RowAlign<'a>>,
::core::option::Option<jacquard_common::types::value::Data<'a>>,
::core::option::Option<RowGap<'a>>,
::core::option::Option<bool>,
::core::option::Option<RowJustify<'a>>,
::core::option::Option<bool>,
::core::option::Option<bool>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Row<'a> {
pub fn new() -> RowBuilder<'a, row_state::Empty> {
RowBuilder::new()
}
}
impl<'a> RowBuilder<'a, row_state::Empty> {
pub fn new() -> Self {
RowBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: row_state::State> RowBuilder<'a, S> {
pub fn align(mut self, value: impl Into<Option<RowAlign<'a>>>) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_align(mut self, value: Option<RowAlign<'a>>) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> RowBuilder<'a, S>
where
S: row_state::State,
S::Children: row_state::IsUnset,
{
pub fn children(
mut self,
value: impl Into<jacquard_common::types::value::Data<'a>>,
) -> RowBuilder<'a, row_state::SetChildren<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
RowBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: row_state::State> RowBuilder<'a, S> {
pub fn gap(mut self, value: impl Into<Option<RowGap<'a>>>) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_gap(mut self, value: Option<RowGap<'a>>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: row_state::State> RowBuilder<'a, S> {
pub fn inset(mut self, value: impl Into<Option<bool>>) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_inset(mut self, value: Option<bool>) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S: row_state::State> RowBuilder<'a, S> {
pub fn justify(mut self, value: impl Into<Option<RowJustify<'a>>>) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_justify(mut self, value: Option<RowJustify<'a>>) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S: row_state::State> RowBuilder<'a, S> {
pub fn opaque(mut self, value: impl Into<Option<bool>>) -> Self {
self.__unsafe_private_named.5 = value.into();
self
}
pub fn maybe_opaque(mut self, value: Option<bool>) -> Self {
self.__unsafe_private_named.5 = value;
self
}
}
impl<'a, S: row_state::State> RowBuilder<'a, S> {
pub fn sticky(mut self, value: impl Into<Option<bool>>) -> Self {
self.__unsafe_private_named.6 = value.into();
self
}
pub fn maybe_sticky(mut self, value: Option<bool>) -> Self {
self.__unsafe_private_named.6 = value;
self
}
}
impl<'a, S> RowBuilder<'a, S>
where
S: row_state::State,
S::Children: row_state::IsSet,
{
pub fn build(self) -> Row<'a> {
Row {
align: self.__unsafe_private_named.0,
children: self.__unsafe_private_named.1.unwrap(),
gap: self.__unsafe_private_named.2,
inset: self.__unsafe_private_named.3,
justify: self.__unsafe_private_named.4,
opaque: self.__unsafe_private_named.5,
sticky: self.__unsafe_private_named.6,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Row<'a> {
Row {
align: self.__unsafe_private_named.0,
children: self.__unsafe_private_named.1.unwrap(),
gap: self.__unsafe_private_named.2,
inset: self.__unsafe_private_named.3,
justify: self.__unsafe_private_named.4,
opaque: self.__unsafe_private_named.5,
sticky: self.__unsafe_private_named.6,
extra_data: Some(extra_data),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RowAlign<'a> {
Start,
Center,
End,
Stretch,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> RowAlign<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for RowAlign<'a> {
fn from(s: &'a str) -> Self {
match s {
"start" => Self::Start,
"center" => Self::Center,
"end" => Self::End,
"stretch" => Self::Stretch,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for RowAlign<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"start" => Self::Start,
"center" => Self::Center,
"end" => Self::End,
"stretch" => Self::Stretch,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for RowAlign<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for RowAlign<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for RowAlign<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for RowAlign<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for RowAlign<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for RowAlign<'_> {
type Output = RowAlign<'static>;
fn into_static(self) -> Self::Output {
match self {
RowAlign::Start => RowAlign::Start,
RowAlign::Center => RowAlign::Center,
RowAlign::End => RowAlign::End,
RowAlign::Stretch => RowAlign::Stretch,
RowAlign::Other(v) => RowAlign::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RowGap<'a> {
None,
Small,
Medium,
Large,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> RowGap<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for RowGap<'a> {
fn from(s: &'a str) -> Self {
match s {
"none" => Self::None,
"small" => Self::Small,
"medium" => Self::Medium,
"large" => Self::Large,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for RowGap<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"none" => Self::None,
"small" => Self::Small,
"medium" => Self::Medium,
"large" => Self::Large,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for RowGap<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for RowGap<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for RowGap<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for RowGap<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for RowGap<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for RowGap<'_> {
type Output = RowGap<'static>;
fn into_static(self) -> Self::Output {
match self {
RowGap::None => RowGap::None,
RowGap::Small => RowGap::Small,
RowGap::Medium => RowGap::Medium,
RowGap::Large => RowGap::Large,
RowGap::Other(v) => RowGap::Other(v.into_static()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RowJustify<'a> {
Start,
Center,
End,
Between,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> RowJustify<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for RowJustify<'a> {
fn from(s: &'a str) -> Self {
match s {
"start" => Self::Start,
"center" => Self::Center,
"end" => Self::End,
"between" => Self::Between,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for RowJustify<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"start" => Self::Start,
"center" => Self::Center,
"end" => Self::End,
"between" => Self::Between,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for RowJustify<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for RowJustify<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for RowJustify<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for RowJustify<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for RowJustify<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for RowJustify<'_> {
type Output = RowJustify<'static>;
fn into_static(self) -> Self::Output {
match self {
RowJustify::Start => RowJustify::Start,
RowJustify::Center => RowJustify::Center,
RowJustify::End => RowJustify::End,
RowJustify::Between => RowJustify::Between,
RowJustify::Other(v) => RowJustify::Other(v.into_static()),
}
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct RowOutput<'a> {
#[serde(flatten)]
#[serde(borrow)]
pub value: crate::at_inlay::Response<'a>,
}
pub struct RowResponse;
impl jacquard_common::xrpc::XrpcResp for RowResponse {
const NSID: &'static str = "org.atsui.Row";
const ENCODING: &'static str = "application/json";
type Output<'de> = RowOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for Row<'a> {
const NSID: &'static str = "org.atsui.Row";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = RowResponse;
}
pub struct RowRequest;
impl jacquard_common::xrpc::XrpcEndpoint for RowRequest {
const PATH: &'static str = "/xrpc/org.atsui.Row";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = Row<'de>;
type Response = RowResponse;
}