pub mod gate;
pub mod message;
pub mod profile;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
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::app_bsky::actor::ProfileViewBasic;
use crate::place_stream::chat::profile::Profile;
use crate::place_stream::chat;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MessageView<'a> {
#[serde(borrow)]
pub author: ProfileViewBasic<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub chat_profile: Option<Profile<'a>>,
#[serde(borrow)]
pub cid: Cid<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted: Option<bool>,
pub indexed_at: Datetime,
#[serde(borrow)]
pub record: Data<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub reply_to: Option<MessageViewReplyTo<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
#[jacquard_derive::open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum MessageViewReplyTo<'a> {
#[serde(rename = "place.stream.chat.defs#messageView")]
MessageView(Box<chat::MessageView<'a>>),
}
impl<'a> LexiconSchema for MessageView<'a> {
fn nsid() -> &'static str {
"place.stream.chat.defs"
}
fn def_name() -> &'static str {
"messageView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_chat_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod message_view_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 Cid;
type Uri;
type Record;
type IndexedAt;
type Author;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Uri = Unset;
type Record = Unset;
type IndexedAt = Unset;
type Author = Unset;
}
pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCid<S> {}
impl<S: State> State for SetCid<S> {
type Cid = Set<members::cid>;
type Uri = S::Uri;
type Record = S::Record;
type IndexedAt = S::IndexedAt;
type Author = S::Author;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Cid = S::Cid;
type Uri = Set<members::uri>;
type Record = S::Record;
type IndexedAt = S::IndexedAt;
type Author = S::Author;
}
pub struct SetRecord<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRecord<S> {}
impl<S: State> State for SetRecord<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Record = Set<members::record>;
type IndexedAt = S::IndexedAt;
type Author = S::Author;
}
pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
impl<S: State> State for SetIndexedAt<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Record = S::Record;
type IndexedAt = Set<members::indexed_at>;
type Author = S::Author;
}
pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAuthor<S> {}
impl<S: State> State for SetAuthor<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Record = S::Record;
type IndexedAt = S::IndexedAt;
type Author = Set<members::author>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct uri(());
pub struct record(());
pub struct indexed_at(());
pub struct author(());
}
}
pub struct MessageViewBuilder<'a, S: message_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ProfileViewBasic<'a>>,
Option<Profile<'a>>,
Option<Cid<'a>>,
Option<bool>,
Option<Datetime>,
Option<Data<'a>>,
Option<MessageViewReplyTo<'a>>,
Option<AtUri<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> MessageView<'a> {
pub fn new() -> MessageViewBuilder<'a, message_view_state::Empty> {
MessageViewBuilder::new()
}
}
impl<'a> MessageViewBuilder<'a, message_view_state::Empty> {
pub fn new() -> Self {
MessageViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> MessageViewBuilder<'a, S>
where
S: message_view_state::State,
S::Author: message_view_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<ProfileViewBasic<'a>>,
) -> MessageViewBuilder<'a, message_view_state::SetAuthor<S>> {
self._fields.0 = Option::Some(value.into());
MessageViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: message_view_state::State> MessageViewBuilder<'a, S> {
pub fn chat_profile(mut self, value: impl Into<Option<Profile<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_chat_profile(mut self, value: Option<Profile<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> MessageViewBuilder<'a, S>
where
S: message_view_state::State,
S::Cid: message_view_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<'a>>,
) -> MessageViewBuilder<'a, message_view_state::SetCid<S>> {
self._fields.2 = Option::Some(value.into());
MessageViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: message_view_state::State> MessageViewBuilder<'a, S> {
pub fn deleted(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_deleted(mut self, value: Option<bool>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> MessageViewBuilder<'a, S>
where
S: message_view_state::State,
S::IndexedAt: message_view_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> MessageViewBuilder<'a, message_view_state::SetIndexedAt<S>> {
self._fields.4 = Option::Some(value.into());
MessageViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MessageViewBuilder<'a, S>
where
S: message_view_state::State,
S::Record: message_view_state::IsUnset,
{
pub fn record(
mut self,
value: impl Into<Data<'a>>,
) -> MessageViewBuilder<'a, message_view_state::SetRecord<S>> {
self._fields.5 = Option::Some(value.into());
MessageViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: message_view_state::State> MessageViewBuilder<'a, S> {
pub fn reply_to(mut self, value: impl Into<Option<MessageViewReplyTo<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_reply_to(mut self, value: Option<MessageViewReplyTo<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> MessageViewBuilder<'a, S>
where
S: message_view_state::State,
S::Uri: message_view_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> MessageViewBuilder<'a, message_view_state::SetUri<S>> {
self._fields.7 = Option::Some(value.into());
MessageViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MessageViewBuilder<'a, S>
where
S: message_view_state::State,
S::Cid: message_view_state::IsSet,
S::Uri: message_view_state::IsSet,
S::Record: message_view_state::IsSet,
S::IndexedAt: message_view_state::IsSet,
S::Author: message_view_state::IsSet,
{
pub fn build(self) -> MessageView<'a> {
MessageView {
author: self._fields.0.unwrap(),
chat_profile: self._fields.1,
cid: self._fields.2.unwrap(),
deleted: self._fields.3,
indexed_at: self._fields.4.unwrap(),
record: self._fields.5.unwrap(),
reply_to: self._fields.6,
uri: self._fields.7.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> MessageView<'a> {
MessageView {
author: self._fields.0.unwrap(),
chat_profile: self._fields.1,
cid: self._fields.2.unwrap(),
deleted: self._fields.3,
indexed_at: self._fields.4.unwrap(),
record: self._fields.5.unwrap(),
reply_to: self._fields.6,
uri: self._fields.7.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_place_stream_chat_defs() -> 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.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("messageView"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("uri"), SmolStr::new_static("cid"),
SmolStr::new_static("author"), SmolStr::new_static("record"),
SmolStr::new_static("indexedAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"app.bsky.actor.defs#profileViewBasic",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("chatProfile"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("place.stream.chat.profile"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("deleted"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("indexedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("replyTo"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![CowStr::new_static("#messageView")],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}