#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Post<'a> {
#[serde(borrow)]
pub content: jacquard_common::CowStr<'a>,
pub created_at: jacquard_common::types::string::Datetime,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub excerpt: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub featured_image: std::option::Option<crate::app_bsky::embed::images::Image<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub images: std::option::Option<Vec<crate::app_bsky::embed::images::Image<'a>>>,
#[serde(borrow)]
pub slug: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub tags: std::option::Option<Vec<jacquard_common::types::string::AtUri<'a>>>,
#[serde(borrow)]
pub title: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(default = "_default_post_visibility")]
#[serde(borrow)]
pub visibility: std::option::Option<jacquard_common::CowStr<'a>>,
}
fn _default_post_visibility() -> std::option::Option<jacquard_common::CowStr<'static>> {
Some(jacquard_common::CowStr::from("public"))
}
pub mod post_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 Title;
type CreatedAt;
type Content;
type Slug;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Title = Unset;
type CreatedAt = Unset;
type Content = Unset;
type Slug = Unset;
}
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 Title = Set<members::title>;
type CreatedAt = S::CreatedAt;
type Content = S::Content;
type Slug = S::Slug;
}
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 Title = S::Title;
type CreatedAt = Set<members::created_at>;
type Content = S::Content;
type Slug = S::Slug;
}
pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContent<S> {}
impl<S: State> State for SetContent<S> {
type Title = S::Title;
type CreatedAt = S::CreatedAt;
type Content = Set<members::content>;
type Slug = S::Slug;
}
pub struct SetSlug<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSlug<S> {}
impl<S: State> State for SetSlug<S> {
type Title = S::Title;
type CreatedAt = S::CreatedAt;
type Content = S::Content;
type Slug = Set<members::slug>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct title(());
pub struct created_at(());
pub struct content(());
pub struct slug(());
}
}
pub struct PostBuilder<'a, S: post_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<crate::app_bsky::embed::images::Image<'a>>,
::core::option::Option<Vec<crate::app_bsky::embed::images::Image<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<Vec<jacquard_common::types::string::AtUri<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Post<'a> {
pub fn new() -> PostBuilder<'a, post_state::Empty> {
PostBuilder::new()
}
}
impl<'a> PostBuilder<'a, post_state::Empty> {
pub fn new() -> Self {
PostBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PostBuilder<'a, S>
where
S: post_state::State,
S::Content: post_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> PostBuilder<'a, post_state::SetContent<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
PostBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PostBuilder<'a, S>
where
S: post_state::State,
S::CreatedAt: post_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> PostBuilder<'a, post_state::SetCreatedAt<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
PostBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: post_state::State> PostBuilder<'a, S> {
pub fn excerpt(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_excerpt(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: post_state::State> PostBuilder<'a, S> {
pub fn featured_image(
mut self,
value: impl Into<Option<crate::app_bsky::embed::images::Image<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_featured_image(
mut self,
value: Option<crate::app_bsky::embed::images::Image<'a>>,
) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S: post_state::State> PostBuilder<'a, S> {
pub fn images(
mut self,
value: impl Into<Option<Vec<crate::app_bsky::embed::images::Image<'a>>>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_images(
mut self,
value: Option<Vec<crate::app_bsky::embed::images::Image<'a>>>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S> PostBuilder<'a, S>
where
S: post_state::State,
S::Slug: post_state::IsUnset,
{
pub fn slug(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> PostBuilder<'a, post_state::SetSlug<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
PostBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: post_state::State> PostBuilder<'a, S> {
pub fn tags(
mut self,
value: impl Into<Option<Vec<jacquard_common::types::string::AtUri<'a>>>>,
) -> Self {
self.__unsafe_private_named.6 = value.into();
self
}
pub fn maybe_tags(
mut self,
value: Option<Vec<jacquard_common::types::string::AtUri<'a>>>,
) -> Self {
self.__unsafe_private_named.6 = value;
self
}
}
impl<'a, S> PostBuilder<'a, S>
where
S: post_state::State,
S::Title: post_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> PostBuilder<'a, post_state::SetTitle<S>> {
self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
PostBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: post_state::State> PostBuilder<'a, S> {
pub fn visibility(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.8 = value.into();
self
}
pub fn maybe_visibility(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.8 = value;
self
}
}
impl<'a, S> PostBuilder<'a, S>
where
S: post_state::State,
S::Title: post_state::IsSet,
S::CreatedAt: post_state::IsSet,
S::Content: post_state::IsSet,
S::Slug: post_state::IsSet,
{
pub fn build(self) -> Post<'a> {
Post {
content: self.__unsafe_private_named.0.unwrap(),
created_at: self.__unsafe_private_named.1.unwrap(),
excerpt: self.__unsafe_private_named.2,
featured_image: self.__unsafe_private_named.3,
images: self.__unsafe_private_named.4,
slug: self.__unsafe_private_named.5.unwrap(),
tags: self.__unsafe_private_named.6,
title: self.__unsafe_private_named.7.unwrap(),
visibility: self
.__unsafe_private_named
.8
.or_else(|| Some(jacquard_common::CowStr::from("public"))),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Post<'a> {
Post {
content: self.__unsafe_private_named.0.unwrap(),
created_at: self.__unsafe_private_named.1.unwrap(),
excerpt: self.__unsafe_private_named.2,
featured_image: self.__unsafe_private_named.3,
images: self.__unsafe_private_named.4,
slug: self.__unsafe_private_named.5.unwrap(),
tags: self.__unsafe_private_named.6,
title: self.__unsafe_private_named.7.unwrap(),
visibility: self
.__unsafe_private_named
.8
.or_else(|| Some(jacquard_common::CowStr::from("public"))),
extra_data: Some(extra_data),
}
}
}
impl<'a> Post<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, PostRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct PostGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Post<'a>,
}
impl From<PostGetRecordOutput<'_>> for Post<'_> {
fn from(output: PostGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Post<'_> {
const NSID: &'static str = "us.polhem.blog.post";
type Record = PostRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct PostRecord;
impl jacquard_common::xrpc::XrpcResp for PostRecord {
const NSID: &'static str = "us.polhem.blog.post";
const ENCODING: &'static str = "application/json";
type Output<'de> = PostGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for PostRecord {
const NSID: &'static str = "us.polhem.blog.post";
type Record = PostRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Post<'a> {
fn nsid() -> &'static str {
"us.polhem.blog.post"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_us_polhem_blog_post()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.content;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"content",
),
max: 100000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.excerpt {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"excerpt",
),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.slug;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"slug",
),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"title",
),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_us_polhem_blog_post() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("us.polhem.blog.post"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"Record describing a blog post.",
),
),
key: Some(::jacquard_common::CowStr::new_static("tid")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("content"),
::jacquard_common::deps::smol_str::SmolStr::new_static("slug"),
::jacquard_common::deps::smol_str::SmolStr::new_static("createdAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"content",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(100000usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"excerpt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(1000usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"featuredImage",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"app.bsky.embed.images#image",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"images",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"app.bsky.embed.images#image",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"slug",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(100usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"tags",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Reference (AT-URI) to a tag record (us.polhem.blog.tag).",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"title",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(1000usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"visibility",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Tells the visibility of the article to AppView.",
),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}