pub mod item;
#[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, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
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::com_atproto::label::Label;
use crate::com_atproto::label::SelfLabels;
use crate::social_grain::actor::ProfileView;
use crate::social_grain::photo::PhotoView;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Gallery<'a> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub labels: Option<SelfLabels<'a>>,
#[serde(borrow)]
pub title: CowStr<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GalleryGetRecordOutput<'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: Gallery<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GalleryView<'a> {
#[serde(borrow)]
pub cid: Cid<'a>,
#[serde(borrow)]
pub creator: ProfileView<'a>,
pub indexed_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub items: Option<Vec<PhotoView<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub labels: Option<Vec<Label<'a>>>,
#[serde(borrow)]
pub record: Data<'a>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
impl<'a> Gallery<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, GalleryRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GalleryRecord;
impl XrpcResp for GalleryRecord {
const NSID: &'static str = "social.grain.gallery";
const ENCODING: &'static str = "application/json";
type Output<'de> = GalleryGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<GalleryGetRecordOutput<'_>> for Gallery<'_> {
fn from(output: GalleryGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Gallery<'_> {
const NSID: &'static str = "social.grain.gallery";
type Record = GalleryRecord;
}
impl Collection for GalleryRecord {
const NSID: &'static str = "social.grain.gallery";
type Record = GalleryRecord;
}
impl<'a> LexiconSchema for Gallery<'a> {
fn nsid() -> &'static str {
"social.grain.gallery"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_social_grain_gallery()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for GalleryView<'a> {
fn nsid() -> &'static str {
"social.grain.gallery.defs"
}
fn def_name() -> &'static str {
"galleryView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_social_grain_gallery_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod gallery_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 CreatedAt;
type Title;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Title = Unset;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type CreatedAt = Set<members::created_at>;
type Title = S::Title;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type CreatedAt = S::CreatedAt;
type Title = Set<members::title>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct title(());
}
}
pub struct GalleryBuilder<'a, S: gallery_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<SelfLabels<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Gallery<'a> {
pub fn new() -> GalleryBuilder<'a, gallery_state::Empty> {
GalleryBuilder::new()
}
}
impl<'a> GalleryBuilder<'a, gallery_state::Empty> {
pub fn new() -> Self {
GalleryBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryBuilder<'a, S>
where
S: gallery_state::State,
S::CreatedAt: gallery_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> GalleryBuilder<'a, gallery_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
GalleryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: gallery_state::State> GalleryBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: gallery_state::State> GalleryBuilder<'a, S> {
pub fn labels(mut self, value: impl Into<Option<SelfLabels<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_labels(mut self, value: Option<SelfLabels<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> GalleryBuilder<'a, S>
where
S: gallery_state::State,
S::Title: gallery_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> GalleryBuilder<'a, gallery_state::SetTitle<S>> {
self._fields.3 = Option::Some(value.into());
GalleryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryBuilder<'a, S>
where
S: gallery_state::State,
S::CreatedAt: gallery_state::IsSet,
S::Title: gallery_state::IsSet,
{
pub fn build(self) -> Gallery<'a> {
Gallery {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
labels: self._fields.2,
title: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Gallery<'a> {
Gallery {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
labels: self._fields.2,
title: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_social_grain_gallery() -> 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("social.grain.gallery"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("title"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("labels"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Self-label values for this post. Effectively content warnings.",
),
),
refs: vec![
CowStr::new_static("com.atproto.label.defs#selfLabels")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
max_length: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod gallery_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 Record;
type Creator;
type IndexedAt;
type Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Record = Unset;
type Creator = Unset;
type IndexedAt = Unset;
type Uri = 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 Record = S::Record;
type Creator = S::Creator;
type IndexedAt = S::IndexedAt;
type Uri = S::Uri;
}
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 Record = Set<members::record>;
type Creator = S::Creator;
type IndexedAt = S::IndexedAt;
type Uri = S::Uri;
}
pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreator<S> {}
impl<S: State> State for SetCreator<S> {
type Cid = S::Cid;
type Record = S::Record;
type Creator = Set<members::creator>;
type IndexedAt = S::IndexedAt;
type Uri = S::Uri;
}
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 Record = S::Record;
type Creator = S::Creator;
type IndexedAt = Set<members::indexed_at>;
type Uri = S::Uri;
}
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 Record = S::Record;
type Creator = S::Creator;
type IndexedAt = S::IndexedAt;
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct record(());
pub struct creator(());
pub struct indexed_at(());
pub struct uri(());
}
}
pub struct GalleryViewBuilder<'a, S: gallery_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Cid<'a>>,
Option<ProfileView<'a>>,
Option<Datetime>,
Option<Vec<PhotoView<'a>>>,
Option<Vec<Label<'a>>>,
Option<Data<'a>>,
Option<AtUri<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GalleryView<'a> {
pub fn new() -> GalleryViewBuilder<'a, gallery_view_state::Empty> {
GalleryViewBuilder::new()
}
}
impl<'a> GalleryViewBuilder<'a, gallery_view_state::Empty> {
pub fn new() -> Self {
GalleryViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryViewBuilder<'a, S>
where
S: gallery_view_state::State,
S::Cid: gallery_view_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<'a>>,
) -> GalleryViewBuilder<'a, gallery_view_state::SetCid<S>> {
self._fields.0 = Option::Some(value.into());
GalleryViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryViewBuilder<'a, S>
where
S: gallery_view_state::State,
S::Creator: gallery_view_state::IsUnset,
{
pub fn creator(
mut self,
value: impl Into<ProfileView<'a>>,
) -> GalleryViewBuilder<'a, gallery_view_state::SetCreator<S>> {
self._fields.1 = Option::Some(value.into());
GalleryViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryViewBuilder<'a, S>
where
S: gallery_view_state::State,
S::IndexedAt: gallery_view_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> GalleryViewBuilder<'a, gallery_view_state::SetIndexedAt<S>> {
self._fields.2 = Option::Some(value.into());
GalleryViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: gallery_view_state::State> GalleryViewBuilder<'a, S> {
pub fn items(mut self, value: impl Into<Option<Vec<PhotoView<'a>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_items(mut self, value: Option<Vec<PhotoView<'a>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: gallery_view_state::State> GalleryViewBuilder<'a, S> {
pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_labels(mut self, value: Option<Vec<Label<'a>>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> GalleryViewBuilder<'a, S>
where
S: gallery_view_state::State,
S::Record: gallery_view_state::IsUnset,
{
pub fn record(
mut self,
value: impl Into<Data<'a>>,
) -> GalleryViewBuilder<'a, gallery_view_state::SetRecord<S>> {
self._fields.5 = Option::Some(value.into());
GalleryViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryViewBuilder<'a, S>
where
S: gallery_view_state::State,
S::Uri: gallery_view_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> GalleryViewBuilder<'a, gallery_view_state::SetUri<S>> {
self._fields.6 = Option::Some(value.into());
GalleryViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GalleryViewBuilder<'a, S>
where
S: gallery_view_state::State,
S::Cid: gallery_view_state::IsSet,
S::Record: gallery_view_state::IsSet,
S::Creator: gallery_view_state::IsSet,
S::IndexedAt: gallery_view_state::IsSet,
S::Uri: gallery_view_state::IsSet,
{
pub fn build(self) -> GalleryView<'a> {
GalleryView {
cid: self._fields.0.unwrap(),
creator: self._fields.1.unwrap(),
indexed_at: self._fields.2.unwrap(),
items: self._fields.3,
labels: self._fields.4,
record: self._fields.5.unwrap(),
uri: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> GalleryView<'a> {
GalleryView {
cid: self._fields.0.unwrap(),
creator: self._fields.1.unwrap(),
indexed_at: self._fields.2.unwrap(),
items: self._fields.3,
labels: self._fields.4,
record: self._fields.5.unwrap(),
uri: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_social_grain_gallery_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("social.grain.gallery.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("galleryView"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("uri"), SmolStr::new_static("cid"),
SmolStr::new_static("creator"),
SmolStr::new_static("record"),
SmolStr::new_static("indexedAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("creator"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"social.grain.actor.defs#profileView",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("indexedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("items"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("social.grain.photo.defs#photoView")
],
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("labels"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.label.defs#label"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}