pub mod create_draft;
pub mod delete_draft;
pub mod get_drafts;
pub mod update_draft;
#[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::{Datetime, Language, Tid, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_bsky::draft;
use crate::app_bsky::feed::postgate::DisableRule;
use crate::app_bsky::feed::threadgate::FollowerRule;
use crate::app_bsky::feed::threadgate::FollowingRule;
use crate::app_bsky::feed::threadgate::ListRule;
use crate::app_bsky::feed::threadgate::MentionRule;
use crate::com_atproto::label::SelfLabels;
use crate::com_atproto::repo::strong_ref::StrongRef;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Draft<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_name: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub langs: Option<Vec<Language>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub postgate_embedding_rules: Option<Vec<DisableRule<S>>>,
pub posts: Vec<draft::DraftPost<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub threadgate_allow: Option<Vec<DraftThreadgateAllowItem<S>>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum DraftThreadgateAllowItem<S: BosStr = DefaultStr> {
#[serde(rename = "app.bsky.feed.threadgate#mentionRule")]
ThreadgateMentionRule(Box<MentionRule<S>>),
#[serde(rename = "app.bsky.feed.threadgate#followerRule")]
ThreadgateFollowerRule(Box<FollowerRule<S>>),
#[serde(rename = "app.bsky.feed.threadgate#followingRule")]
ThreadgateFollowingRule(Box<FollowingRule<S>>),
#[serde(rename = "app.bsky.feed.threadgate#listRule")]
ThreadgateListRule(Box<ListRule<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftEmbedCaption<S: BosStr = DefaultStr> {
pub content: S,
pub lang: Language,
#[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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftEmbedExternal<S: BosStr = DefaultStr> {
pub uri: UriValue<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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftEmbedImage<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
pub local_ref: draft::DraftEmbedLocalRef<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 DraftEmbedLocalRef<S: BosStr = DefaultStr> {
pub path: 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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftEmbedRecord<S: BosStr = DefaultStr> {
pub record: StrongRef<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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftEmbedVideo<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub captions: Option<Vec<draft::DraftEmbedCaption<S>>>,
pub local_ref: draft::DraftEmbedLocalRef<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 DraftPost<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub embed_externals: Option<Vec<draft::DraftEmbedExternal<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub embed_images: Option<Vec<draft::DraftEmbedImage<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub embed_records: Option<Vec<draft::DraftEmbedRecord<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub embed_videos: Option<Vec<draft::DraftEmbedVideo<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<SelfLabels<S>>,
pub text: 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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftView<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub draft: draft::Draft<S>,
pub id: Tid,
pub updated_at: Datetime,
#[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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DraftWithId<S: BosStr = DefaultStr> {
pub draft: draft::Draft<S>,
pub id: Tid,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Draft<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draft"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.device_id {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("device_id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.device_name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("device_name"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.langs {
#[allow(unused_comparisons)]
if value.len() > 3usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("langs"),
max: 3usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.postgate_embedding_rules {
#[allow(unused_comparisons)]
if value.len() > 5usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("postgate_embedding_rules"),
max: 5usize,
actual: value.len(),
});
}
}
{
let value = &self.posts;
#[allow(unused_comparisons)]
if value.len() > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("posts"),
max: 100usize,
actual: value.len(),
});
}
}
{
let value = &self.posts;
#[allow(unused_comparisons)]
if value.len() < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("posts"),
min: 1usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.threadgate_allow {
#[allow(unused_comparisons)]
if value.len() > 5usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("threadgate_allow"),
max: 5usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftEmbedCaption<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftEmbedCaption"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.content;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("content"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftEmbedExternal<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftEmbedExternal"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftEmbedImage<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftEmbedImage"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.alt {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("alt"),
max: 2000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftEmbedLocalRef<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftEmbedLocalRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.path;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1024usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("path"),
max: 1024usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.path;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("path"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftEmbedRecord<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftEmbedRecord"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftEmbedVideo<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftEmbedVideo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.alt {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("alt"),
max: 2000usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.captions {
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("captions"),
max: 20usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftPost<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftPost"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.embed_externals {
#[allow(unused_comparisons)]
if value.len() > 1usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("embed_externals"),
max: 1usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.embed_images {
#[allow(unused_comparisons)]
if value.len() > 4usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("embed_images"),
max: 4usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.embed_records {
#[allow(unused_comparisons)]
if value.len() > 1usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("embed_records"),
max: 1usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.embed_videos {
#[allow(unused_comparisons)]
if value.len() > 1usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("embed_videos"),
max: 1usize,
actual: value.len(),
});
}
}
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.text;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 1000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftView<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftWithId<S> {
fn nsid() -> &'static str {
"app.bsky.draft.defs"
}
fn def_name() -> &'static str {
"draftWithId"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_draft_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod draft_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 Posts;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Posts = Unset;
}
pub struct SetPosts<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPosts<St> {}
impl<St: State> State for SetPosts<St> {
type Posts = Set<members::posts>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct posts(());
}
}
pub struct DraftBuilder<S: BosStr, St: draft_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<S>,
Option<Vec<Language>>,
Option<Vec<DisableRule<S>>>,
Option<Vec<draft::DraftPost<S>>>,
Option<Vec<DraftThreadgateAllowItem<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Draft<S> {
pub fn new() -> DraftBuilder<S, draft_state::Empty> {
DraftBuilder::new()
}
}
impl<S: BosStr> DraftBuilder<S, draft_state::Empty> {
pub fn new() -> Self {
DraftBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: draft_state::State> DraftBuilder<S, St> {
pub fn device_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_device_id(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: draft_state::State> DraftBuilder<S, St> {
pub fn device_name(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_device_name(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: draft_state::State> DraftBuilder<S, St> {
pub fn langs(mut self, value: impl Into<Option<Vec<Language>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_langs(mut self, value: Option<Vec<Language>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: draft_state::State> DraftBuilder<S, St> {
pub fn postgate_embedding_rules(
mut self,
value: impl Into<Option<Vec<DisableRule<S>>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_postgate_embedding_rules(mut self, value: Option<Vec<DisableRule<S>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> DraftBuilder<S, St>
where
St: draft_state::State,
St::Posts: draft_state::IsUnset,
{
pub fn posts(
mut self,
value: impl Into<Vec<draft::DraftPost<S>>>,
) -> DraftBuilder<S, draft_state::SetPosts<St>> {
self._fields.4 = Option::Some(value.into());
DraftBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: draft_state::State> DraftBuilder<S, St> {
pub fn threadgate_allow(
mut self,
value: impl Into<Option<Vec<DraftThreadgateAllowItem<S>>>>,
) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_threadgate_allow(
mut self,
value: Option<Vec<DraftThreadgateAllowItem<S>>>,
) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St> DraftBuilder<S, St>
where
St: draft_state::State,
St::Posts: draft_state::IsSet,
{
pub fn build(self) -> Draft<S> {
Draft {
device_id: self._fields.0,
device_name: self._fields.1,
langs: self._fields.2,
postgate_embedding_rules: self._fields.3,
posts: self._fields.4.unwrap(),
threadgate_allow: self._fields.5,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Draft<S> {
Draft {
device_id: self._fields.0,
device_name: self._fields.1,
langs: self._fields.2,
postgate_embedding_rules: self._fields.3,
posts: self._fields.4.unwrap(),
threadgate_allow: self._fields.5,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_bsky_draft_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("app.bsky.draft.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("draft"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("A draft containing an array of draft posts."),
),
required: Some(vec![SmolStr::new_static("posts")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("deviceId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"UUIDv4 identifier of the device that created this draft.",
),
),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("deviceName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The device and/or platform on which the draft was created.",
),
),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("langs"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Indicates human language of posts primary text content.",
),
),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Language),
..Default::default()
}),
max_length: Some(3usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postgateEmbeddingRules"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Embedding rules for the postgates to be created when this draft is published.",
),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("app.bsky.feed.postgate#disableRule")
],
..Default::default()
}),
max_length: Some(5usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("posts"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Array of draft posts that compose this draft.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#draftPost"),
..Default::default()
}),
min_length: Some(1usize),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("threadgateAllow"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Allow-rules for the threadgate to be created when this draft is published.",
),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("app.bsky.feed.threadgate#mentionRule"),
CowStr::new_static("app.bsky.feed.threadgate#followerRule"),
CowStr::new_static("app.bsky.feed.threadgate#followingRule"),
CowStr::new_static("app.bsky.feed.threadgate#listRule")
],
..Default::default()
}),
max_length: Some(5usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftEmbedCaption"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("lang"),
SmolStr::new_static("content"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::String(LexString {
max_length: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lang"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Language),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftEmbedExternal"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftEmbedImage"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("localRef")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
max_graphemes: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("localRef"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedLocalRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftEmbedLocalRef"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("path")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("path"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Local, on-device ref to file to be embedded. Embeds are currently device-bound for drafts.",
),
),
min_length: Some(1usize),
max_length: Some(1024usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftEmbedRecord"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("record")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftEmbedVideo"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("localRef")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
max_graphemes: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("captions"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedCaption"),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("localRef"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedLocalRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftPost"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("One of the posts that compose a draft."),
),
required: Some(vec![SmolStr::new_static("text")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("embedExternals"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedExternal"),
..Default::default()
}),
max_length: Some(1usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("embedImages"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedImage"),
..Default::default()
}),
max_length: Some(4usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("embedRecords"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedRecord"),
..Default::default()
}),
max_length: Some(1usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("embedVideos"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#draftEmbedVideo"),
..Default::default()
}),
max_length: Some(1usize),
..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("text"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The primary post content. It has a higher limit than post contents to allow storing a larger text that can later be refined into smaller posts.",
),
),
max_length: Some(10000usize),
max_graphemes: Some(1000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftView"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("View to present drafts data to users.")),
required: Some(vec![
SmolStr::new_static("id"),
SmolStr::new_static("draft"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("updatedAt"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The time the draft was created.",
)),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draft"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#draft"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"A TID to be used as a draft identifier.",
)),
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The time the draft was last updated.",
)),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftWithId"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A draft with an identifier, used to store drafts in private storage (stash).",
),
),
required: Some(
vec![SmolStr::new_static("id"), SmolStr::new_static("draft")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("draft"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#draft"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"A TID to be used as a draft identifier.",
),
),
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod draft_embed_caption_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 Content;
type Lang;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Content = Unset;
type Lang = Unset;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Content = Set<members::content>;
type Lang = St::Lang;
}
pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLang<St> {}
impl<St: State> State for SetLang<St> {
type Content = St::Content;
type Lang = Set<members::lang>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content(());
pub struct lang(());
}
}
pub struct DraftEmbedCaptionBuilder<S: BosStr, St: draft_embed_caption_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<Language>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftEmbedCaption<S> {
pub fn new() -> DraftEmbedCaptionBuilder<S, draft_embed_caption_state::Empty> {
DraftEmbedCaptionBuilder::new()
}
}
impl<S: BosStr> DraftEmbedCaptionBuilder<S, draft_embed_caption_state::Empty> {
pub fn new() -> Self {
DraftEmbedCaptionBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedCaptionBuilder<S, St>
where
St: draft_embed_caption_state::State,
St::Content: draft_embed_caption_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<S>,
) -> DraftEmbedCaptionBuilder<S, draft_embed_caption_state::SetContent<St>> {
self._fields.0 = Option::Some(value.into());
DraftEmbedCaptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedCaptionBuilder<S, St>
where
St: draft_embed_caption_state::State,
St::Lang: draft_embed_caption_state::IsUnset,
{
pub fn lang(
mut self,
value: impl Into<Language>,
) -> DraftEmbedCaptionBuilder<S, draft_embed_caption_state::SetLang<St>> {
self._fields.1 = Option::Some(value.into());
DraftEmbedCaptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedCaptionBuilder<S, St>
where
St: draft_embed_caption_state::State,
St::Content: draft_embed_caption_state::IsSet,
St::Lang: draft_embed_caption_state::IsSet,
{
pub fn build(self) -> DraftEmbedCaption<S> {
DraftEmbedCaption {
content: self._fields.0.unwrap(),
lang: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedCaption<S> {
DraftEmbedCaption {
content: self._fields.0.unwrap(),
lang: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod draft_embed_external_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct DraftEmbedExternalBuilder<S: BosStr, St: draft_embed_external_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<UriValue<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftEmbedExternal<S> {
pub fn new() -> DraftEmbedExternalBuilder<S, draft_embed_external_state::Empty> {
DraftEmbedExternalBuilder::new()
}
}
impl<S: BosStr> DraftEmbedExternalBuilder<S, draft_embed_external_state::Empty> {
pub fn new() -> Self {
DraftEmbedExternalBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedExternalBuilder<S, St>
where
St: draft_embed_external_state::State,
St::Uri: draft_embed_external_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<S>>,
) -> DraftEmbedExternalBuilder<S, draft_embed_external_state::SetUri<St>> {
self._fields.0 = Option::Some(value.into());
DraftEmbedExternalBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedExternalBuilder<S, St>
where
St: draft_embed_external_state::State,
St::Uri: draft_embed_external_state::IsSet,
{
pub fn build(self) -> DraftEmbedExternal<S> {
DraftEmbedExternal {
uri: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedExternal<S> {
DraftEmbedExternal {
uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod draft_embed_image_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 LocalRef;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type LocalRef = Unset;
}
pub struct SetLocalRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLocalRef<St> {}
impl<St: State> State for SetLocalRef<St> {
type LocalRef = Set<members::local_ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct local_ref(());
}
}
pub struct DraftEmbedImageBuilder<S: BosStr, St: draft_embed_image_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<draft::DraftEmbedLocalRef<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftEmbedImage<S> {
pub fn new() -> DraftEmbedImageBuilder<S, draft_embed_image_state::Empty> {
DraftEmbedImageBuilder::new()
}
}
impl<S: BosStr> DraftEmbedImageBuilder<S, draft_embed_image_state::Empty> {
pub fn new() -> Self {
DraftEmbedImageBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: draft_embed_image_state::State> DraftEmbedImageBuilder<S, St> {
pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> DraftEmbedImageBuilder<S, St>
where
St: draft_embed_image_state::State,
St::LocalRef: draft_embed_image_state::IsUnset,
{
pub fn local_ref(
mut self,
value: impl Into<draft::DraftEmbedLocalRef<S>>,
) -> DraftEmbedImageBuilder<S, draft_embed_image_state::SetLocalRef<St>> {
self._fields.1 = Option::Some(value.into());
DraftEmbedImageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedImageBuilder<S, St>
where
St: draft_embed_image_state::State,
St::LocalRef: draft_embed_image_state::IsSet,
{
pub fn build(self) -> DraftEmbedImage<S> {
DraftEmbedImage {
alt: self._fields.0,
local_ref: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedImage<S> {
DraftEmbedImage {
alt: self._fields.0,
local_ref: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod draft_embed_record_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 Record;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Record = Unset;
}
pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRecord<St> {}
impl<St: State> State for SetRecord<St> {
type Record = Set<members::record>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct record(());
}
}
pub struct DraftEmbedRecordBuilder<S: BosStr, St: draft_embed_record_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<StrongRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftEmbedRecord<S> {
pub fn new() -> DraftEmbedRecordBuilder<S, draft_embed_record_state::Empty> {
DraftEmbedRecordBuilder::new()
}
}
impl<S: BosStr> DraftEmbedRecordBuilder<S, draft_embed_record_state::Empty> {
pub fn new() -> Self {
DraftEmbedRecordBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedRecordBuilder<S, St>
where
St: draft_embed_record_state::State,
St::Record: draft_embed_record_state::IsUnset,
{
pub fn record(
mut self,
value: impl Into<StrongRef<S>>,
) -> DraftEmbedRecordBuilder<S, draft_embed_record_state::SetRecord<St>> {
self._fields.0 = Option::Some(value.into());
DraftEmbedRecordBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedRecordBuilder<S, St>
where
St: draft_embed_record_state::State,
St::Record: draft_embed_record_state::IsSet,
{
pub fn build(self) -> DraftEmbedRecord<S> {
DraftEmbedRecord {
record: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedRecord<S> {
DraftEmbedRecord {
record: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod draft_embed_video_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 LocalRef;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type LocalRef = Unset;
}
pub struct SetLocalRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLocalRef<St> {}
impl<St: State> State for SetLocalRef<St> {
type LocalRef = Set<members::local_ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct local_ref(());
}
}
pub struct DraftEmbedVideoBuilder<S: BosStr, St: draft_embed_video_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<Vec<draft::DraftEmbedCaption<S>>>,
Option<draft::DraftEmbedLocalRef<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftEmbedVideo<S> {
pub fn new() -> DraftEmbedVideoBuilder<S, draft_embed_video_state::Empty> {
DraftEmbedVideoBuilder::new()
}
}
impl<S: BosStr> DraftEmbedVideoBuilder<S, draft_embed_video_state::Empty> {
pub fn new() -> Self {
DraftEmbedVideoBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: draft_embed_video_state::State> DraftEmbedVideoBuilder<S, St> {
pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: draft_embed_video_state::State> DraftEmbedVideoBuilder<S, St> {
pub fn captions(mut self, value: impl Into<Option<Vec<draft::DraftEmbedCaption<S>>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_captions(mut self, value: Option<Vec<draft::DraftEmbedCaption<S>>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> DraftEmbedVideoBuilder<S, St>
where
St: draft_embed_video_state::State,
St::LocalRef: draft_embed_video_state::IsUnset,
{
pub fn local_ref(
mut self,
value: impl Into<draft::DraftEmbedLocalRef<S>>,
) -> DraftEmbedVideoBuilder<S, draft_embed_video_state::SetLocalRef<St>> {
self._fields.2 = Option::Some(value.into());
DraftEmbedVideoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftEmbedVideoBuilder<S, St>
where
St: draft_embed_video_state::State,
St::LocalRef: draft_embed_video_state::IsSet,
{
pub fn build(self) -> DraftEmbedVideo<S> {
DraftEmbedVideo {
alt: self._fields.0,
captions: self._fields.1,
local_ref: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedVideo<S> {
DraftEmbedVideo {
alt: self._fields.0,
captions: self._fields.1,
local_ref: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod draft_view_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 CreatedAt;
type UpdatedAt;
type Draft;
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type UpdatedAt = Unset;
type Draft = Unset;
type Id = Unset;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type CreatedAt = Set<members::created_at>;
type UpdatedAt = St::UpdatedAt;
type Draft = St::Draft;
type Id = St::Id;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type CreatedAt = St::CreatedAt;
type UpdatedAt = Set<members::updated_at>;
type Draft = St::Draft;
type Id = St::Id;
}
pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDraft<St> {}
impl<St: State> State for SetDraft<St> {
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type Draft = Set<members::draft>;
type Id = St::Id;
}
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 CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type Draft = St::Draft;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct updated_at(());
pub struct draft(());
pub struct id(());
}
}
pub struct DraftViewBuilder<S: BosStr, St: draft_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<draft::Draft<S>>,
Option<Tid>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftView<S> {
pub fn new() -> DraftViewBuilder<S, draft_view_state::Empty> {
DraftViewBuilder::new()
}
}
impl<S: BosStr> DraftViewBuilder<S, draft_view_state::Empty> {
pub fn new() -> Self {
DraftViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftViewBuilder<S, St>
where
St: draft_view_state::State,
St::CreatedAt: draft_view_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> DraftViewBuilder<S, draft_view_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
DraftViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftViewBuilder<S, St>
where
St: draft_view_state::State,
St::Draft: draft_view_state::IsUnset,
{
pub fn draft(
mut self,
value: impl Into<draft::Draft<S>>,
) -> DraftViewBuilder<S, draft_view_state::SetDraft<St>> {
self._fields.1 = Option::Some(value.into());
DraftViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftViewBuilder<S, St>
where
St: draft_view_state::State,
St::Id: draft_view_state::IsUnset,
{
pub fn id(mut self, value: impl Into<Tid>) -> DraftViewBuilder<S, draft_view_state::SetId<St>> {
self._fields.2 = Option::Some(value.into());
DraftViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftViewBuilder<S, St>
where
St: draft_view_state::State,
St::UpdatedAt: draft_view_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> DraftViewBuilder<S, draft_view_state::SetUpdatedAt<St>> {
self._fields.3 = Option::Some(value.into());
DraftViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftViewBuilder<S, St>
where
St: draft_view_state::State,
St::CreatedAt: draft_view_state::IsSet,
St::UpdatedAt: draft_view_state::IsSet,
St::Draft: draft_view_state::IsSet,
St::Id: draft_view_state::IsSet,
{
pub fn build(self) -> DraftView<S> {
DraftView {
created_at: self._fields.0.unwrap(),
draft: self._fields.1.unwrap(),
id: self._fields.2.unwrap(),
updated_at: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftView<S> {
DraftView {
created_at: self._fields.0.unwrap(),
draft: self._fields.1.unwrap(),
id: self._fields.2.unwrap(),
updated_at: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod draft_with_id_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 Draft;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type Draft = 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 Draft = St::Draft;
}
pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDraft<St> {}
impl<St: State> State for SetDraft<St> {
type Id = St::Id;
type Draft = Set<members::draft>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct draft(());
}
}
pub struct DraftWithIdBuilder<S: BosStr, St: draft_with_id_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<draft::Draft<S>>, Option<Tid>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DraftWithId<S> {
pub fn new() -> DraftWithIdBuilder<S, draft_with_id_state::Empty> {
DraftWithIdBuilder::new()
}
}
impl<S: BosStr> DraftWithIdBuilder<S, draft_with_id_state::Empty> {
pub fn new() -> Self {
DraftWithIdBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftWithIdBuilder<S, St>
where
St: draft_with_id_state::State,
St::Draft: draft_with_id_state::IsUnset,
{
pub fn draft(
mut self,
value: impl Into<draft::Draft<S>>,
) -> DraftWithIdBuilder<S, draft_with_id_state::SetDraft<St>> {
self._fields.0 = Option::Some(value.into());
DraftWithIdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftWithIdBuilder<S, St>
where
St: draft_with_id_state::State,
St::Id: draft_with_id_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<Tid>,
) -> DraftWithIdBuilder<S, draft_with_id_state::SetId<St>> {
self._fields.1 = Option::Some(value.into());
DraftWithIdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DraftWithIdBuilder<S, St>
where
St: draft_with_id_state::State,
St::Id: draft_with_id_state::IsSet,
St::Draft: draft_with_id_state::IsSet,
{
pub fn build(self) -> DraftWithId<S> {
DraftWithId {
draft: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftWithId<S> {
DraftWithId {
draft: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}