#[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_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
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::place_stream::chat::profile;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Color<'a> {
pub blue: i64,
pub green: i64,
pub red: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Profile<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub color: Option<profile::Color<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ProfileGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Profile<'a>,
}
impl<'a> Profile<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, ProfileRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for Color<'a> {
fn nsid() -> &'static str {
"place.stream.chat.profile"
}
fn def_name() -> &'static str {
"color"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_chat_profile()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.blue;
if *value > 255i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("blue"),
max: 255i64,
actual: *value,
});
}
}
{
let value = &self.blue;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("blue"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.green;
if *value > 255i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("green"),
max: 255i64,
actual: *value,
});
}
}
{
let value = &self.green;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("green"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.red;
if *value > 255i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("red"),
max: 255i64,
actual: *value,
});
}
}
{
let value = &self.red;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("red"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ProfileRecord;
impl XrpcResp for ProfileRecord {
const NSID: &'static str = "place.stream.chat.profile";
const ENCODING: &'static str = "application/json";
type Output<'de> = ProfileGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<ProfileGetRecordOutput<'_>> for Profile<'_> {
fn from(output: ProfileGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Profile<'_> {
const NSID: &'static str = "place.stream.chat.profile";
type Record = ProfileRecord;
}
impl Collection for ProfileRecord {
const NSID: &'static str = "place.stream.chat.profile";
type Record = ProfileRecord;
}
impl<'a> LexiconSchema for Profile<'a> {
fn nsid() -> &'static str {
"place.stream.chat.profile"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_chat_profile()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod color_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 Blue;
type Red;
type Green;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blue = Unset;
type Red = Unset;
type Green = Unset;
}
pub struct SetBlue<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBlue<S> {}
impl<S: State> State for SetBlue<S> {
type Blue = Set<members::blue>;
type Red = S::Red;
type Green = S::Green;
}
pub struct SetRed<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRed<S> {}
impl<S: State> State for SetRed<S> {
type Blue = S::Blue;
type Red = Set<members::red>;
type Green = S::Green;
}
pub struct SetGreen<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetGreen<S> {}
impl<S: State> State for SetGreen<S> {
type Blue = S::Blue;
type Red = S::Red;
type Green = Set<members::green>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blue(());
pub struct red(());
pub struct green(());
}
}
pub struct ColorBuilder<'a, S: color_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Color<'a> {
pub fn new() -> ColorBuilder<'a, color_state::Empty> {
ColorBuilder::new()
}
}
impl<'a> ColorBuilder<'a, color_state::Empty> {
pub fn new() -> Self {
ColorBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ColorBuilder<'a, S>
where
S: color_state::State,
S::Blue: color_state::IsUnset,
{
pub fn blue(
mut self,
value: impl Into<i64>,
) -> ColorBuilder<'a, color_state::SetBlue<S>> {
self._fields.0 = Option::Some(value.into());
ColorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ColorBuilder<'a, S>
where
S: color_state::State,
S::Green: color_state::IsUnset,
{
pub fn green(
mut self,
value: impl Into<i64>,
) -> ColorBuilder<'a, color_state::SetGreen<S>> {
self._fields.1 = Option::Some(value.into());
ColorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ColorBuilder<'a, S>
where
S: color_state::State,
S::Red: color_state::IsUnset,
{
pub fn red(
mut self,
value: impl Into<i64>,
) -> ColorBuilder<'a, color_state::SetRed<S>> {
self._fields.2 = Option::Some(value.into());
ColorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ColorBuilder<'a, S>
where
S: color_state::State,
S::Blue: color_state::IsSet,
S::Red: color_state::IsSet,
S::Green: color_state::IsSet,
{
pub fn build(self) -> Color<'a> {
Color {
blue: self._fields.0.unwrap(),
green: self._fields.1.unwrap(),
red: 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>,
>,
) -> Color<'a> {
Color {
blue: self._fields.0.unwrap(),
green: self._fields.1.unwrap(),
red: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_place_stream_chat_profile() -> 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("place.stream.chat.profile"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("color"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Customizations for the color of a user's name in chat",
),
),
required: Some(
vec![
SmolStr::new_static("red"), SmolStr::new_static("green"),
SmolStr::new_static("blue")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blue"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(255i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("green"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(255i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("red"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(255i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Record containing customizations for a user's chat profile.",
),
),
key: Some(CowStr::new_static("literal:self")),
record: LexRecordRecord::Object(LexObject {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("color"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#color"),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod profile_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 {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct ProfileBuilder<'a, S: profile_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<profile::Color<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Profile<'a> {
pub fn new() -> ProfileBuilder<'a, profile_state::Empty> {
ProfileBuilder::new()
}
}
impl<'a> ProfileBuilder<'a, profile_state::Empty> {
pub fn new() -> Self {
ProfileBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn color(mut self, value: impl Into<Option<profile::Color<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_color(mut self, value: Option<profile::Color<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
{
pub fn build(self) -> Profile<'a> {
Profile {
color: self._fields.0,
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>,
>,
) -> Profile<'a> {
Profile {
color: self._fields.0,
extra_data: Some(extra_data),
}
}
}