pub mod allow;
pub mod push_notify;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Tid, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::win_tomo_x::pushat;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
pub type DeviceList<S = DefaultStr> = Vec<pushat::DeviceListItem<S>>;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DeviceListItem<S: BosStr = DefaultStr> {
#[serde(default = "_default_device_list_item_current")]
pub current: bool,
pub id: Tid,
pub name: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct NotifyBody<S: BosStr = DefaultStr> {
pub body: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon: Option<UriValue<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link: Option<UriValue<S>>,
pub title: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for DeviceListItem<S> {
fn nsid() -> &'static str {
"win.tomo-x.pushat.defs"
}
fn def_name() -> &'static str {
"deviceListItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_win_tomo_x_pushat_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 300usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 300usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 30usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("name"),
max: 30usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for NotifyBody<S> {
fn nsid() -> &'static str {
"win.tomo-x.pushat.defs"
}
fn def_name() -> &'static str {
"notifyBody"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_win_tomo_x_pushat_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn _default_device_list_item_current() -> bool {
false
}
pub mod device_list_item_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 Id;
type Name;
type Current;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type Name = Unset;
type Current = Unset;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Id = Set<members::id>;
type Name = St::Name;
type Current = St::Current;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Id = St::Id;
type Name = Set<members::name>;
type Current = St::Current;
}
pub struct SetCurrent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCurrent<St> {}
impl<St: State> State for SetCurrent<St> {
type Id = St::Id;
type Name = St::Name;
type Current = Set<members::current>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct name(());
pub struct current(());
}
}
pub struct DeviceListItemBuilder<S: BosStr, St: device_list_item_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<bool>, Option<Tid>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DeviceListItem<S> {
pub fn new() -> DeviceListItemBuilder<S, device_list_item_state::Empty> {
DeviceListItemBuilder::new()
}
}
impl<S: BosStr> DeviceListItemBuilder<S, device_list_item_state::Empty> {
pub fn new() -> Self {
DeviceListItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeviceListItemBuilder<S, St>
where
St: device_list_item_state::State,
St::Current: device_list_item_state::IsUnset,
{
pub fn current(
mut self,
value: impl Into<bool>,
) -> DeviceListItemBuilder<S, device_list_item_state::SetCurrent<St>> {
self._fields.0 = Option::Some(value.into());
DeviceListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeviceListItemBuilder<S, St>
where
St: device_list_item_state::State,
St::Id: device_list_item_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<Tid>,
) -> DeviceListItemBuilder<S, device_list_item_state::SetId<St>> {
self._fields.1 = Option::Some(value.into());
DeviceListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeviceListItemBuilder<S, St>
where
St: device_list_item_state::State,
St::Name: device_list_item_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> DeviceListItemBuilder<S, device_list_item_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
DeviceListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeviceListItemBuilder<S, St>
where
St: device_list_item_state::State,
St::Id: device_list_item_state::IsSet,
St::Name: device_list_item_state::IsSet,
St::Current: device_list_item_state::IsSet,
{
pub fn build(self) -> DeviceListItem<S> {
DeviceListItem {
current: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DeviceListItem<S> {
DeviceListItem {
current: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_win_tomo_x_pushat_defs() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("win.tomo-x.pushat.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("deviceList"),
LexUserType::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#deviceListItem"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("deviceListItem"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("id"),
SmolStr::new_static("current"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("current"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
max_length: Some(300usize),
max_graphemes: Some(30usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notifyBody"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("title"), SmolStr::new_static("body")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("body"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Body text of the notification."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("icon"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The URI of the icon displayed in the notification.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("link"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Experimental — do not use. The URI to open when the notification is clicked.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Title text of the notification."),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}