#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct ContentRef<'a> {
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
}
pub mod content_ref_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
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 Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct ContentRefBuilder<'a, S: content_ref_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> ContentRef<'a> {
pub fn new() -> ContentRefBuilder<'a, content_ref_state::Empty> {
ContentRefBuilder::new()
}
}
impl<'a> ContentRefBuilder<'a, content_ref_state::Empty> {
pub fn new() -> Self {
ContentRefBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None,),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ContentRefBuilder<'a, S>
where
S: content_ref_state::State,
S::Uri: content_ref_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<jacquard_common::types::string::AtUri<'a>>,
) -> ContentRefBuilder<'a, content_ref_state::SetUri<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
ContentRefBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ContentRefBuilder<'a, S>
where
S: content_ref_state::State,
S::Uri: content_ref_state::IsSet,
{
pub fn build(self) -> ContentRef<'a> {
ContentRef {
uri: self.__unsafe_private_named.0.unwrap(),
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>,
>,
) -> ContentRef<'a> {
ContentRef {
uri: self.__unsafe_private_named.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_greengale_document() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("app.greengale.document"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("contentRef"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static(
"Reference to external content via AT-URI. Used in site.standard.document content union.",
),
),
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("uri")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"uri",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"AT-URI pointing to the full document content",
),
),
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,
}),
);
map
},
}),
);
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(
"A markdown document with extended theme and LaTeX support.",
),
),
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("content"),
::jacquard_common::deps::smol_str::SmolStr::new_static("url"),
::jacquard_common::deps::smol_str::SmolStr::new_static("path"),
::jacquard_common::deps::smol_str::SmolStr::new_static("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("publishedAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"blobs",
),
::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.greengale.blog.defs#blobMetadata",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"content",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Markdown content of the document",
),
),
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(
"latex",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
description: None,
default: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"ogp",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"app.greengale.blog.defs#ogp",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"path",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Document path relative to the publication URL (e.g., /handle/rkey)",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(500usize),
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(
"publishedAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Publication timestamp",
),
),
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(
"subtitle",
),
::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(
"tags",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: Some(
::jacquard_common::CowStr::new_static(
"Optional array of strings to tag/categorize the document. Avoid prepending with hashtags.",
),
),
items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(100usize),
min_graphemes: None,
max_graphemes: Some(50usize),
r#enum: None,
r#const: None,
known_values: None,
}),
min_length: None,
max_length: Some(100usize),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"theme",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"app.greengale.blog.defs#theme",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"title",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static("Document title"),
),
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(
"url",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Base publication URL (e.g., https://greengale.app)",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Uri,
),
default: None,
min_length: None,
max_length: Some(2048usize),
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(
"Controls who can view this document",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(16usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ContentRef<'a> {
fn nsid() -> &'static str {
"app.greengale.document"
}
fn def_name() -> &'static str {
"contentRef"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_greengale_document()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Document<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub blobs: std::option::Option<Vec<crate::app_greengale::blog::BlobMetadata<'a>>>,
#[serde(borrow)]
pub content: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(default = "_default_document_latex")]
pub latex: std::option::Option<bool>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub ogp: std::option::Option<crate::app_greengale::blog::Ogp<'a>>,
#[serde(borrow)]
pub path: jacquard_common::CowStr<'a>,
pub published_at: jacquard_common::types::string::Datetime,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub subtitle: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub tags: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub theme: std::option::Option<crate::app_greengale::blog::Theme<'a>>,
#[serde(borrow)]
pub title: jacquard_common::CowStr<'a>,
#[serde(borrow)]
pub url: jacquard_common::types::string::UriValue<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(default = "_default_document_visibility")]
#[serde(borrow)]
pub visibility: std::option::Option<jacquard_common::CowStr<'a>>,
}
fn _default_document_latex() -> std::option::Option<bool> {
Some(false)
}
fn _default_document_visibility() -> std::option::Option<
jacquard_common::CowStr<'static>,
> {
Some(jacquard_common::CowStr::from("public"))
}
pub mod document_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 PublishedAt;
type Title;
type Url;
type Content;
type Path;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type PublishedAt = Unset;
type Title = Unset;
type Url = Unset;
type Content = Unset;
type Path = Unset;
}
pub struct SetPublishedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPublishedAt<S> {}
impl<S: State> State for SetPublishedAt<S> {
type PublishedAt = Set<members::published_at>;
type Title = S::Title;
type Url = S::Url;
type Content = S::Content;
type Path = S::Path;
}
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 PublishedAt = S::PublishedAt;
type Title = Set<members::title>;
type Url = S::Url;
type Content = S::Content;
type Path = S::Path;
}
pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUrl<S> {}
impl<S: State> State for SetUrl<S> {
type PublishedAt = S::PublishedAt;
type Title = S::Title;
type Url = Set<members::url>;
type Content = S::Content;
type Path = S::Path;
}
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 PublishedAt = S::PublishedAt;
type Title = S::Title;
type Url = S::Url;
type Content = Set<members::content>;
type Path = S::Path;
}
pub struct SetPath<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPath<S> {}
impl<S: State> State for SetPath<S> {
type PublishedAt = S::PublishedAt;
type Title = S::Title;
type Url = S::Url;
type Content = S::Content;
type Path = Set<members::path>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct published_at(());
pub struct title(());
pub struct url(());
pub struct content(());
pub struct path(());
}
}
pub struct DocumentBuilder<'a, S: document_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<crate::app_greengale::blog::BlobMetadata<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<bool>,
::core::option::Option<crate::app_greengale::blog::Ogp<'a>>,
::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<Vec<jacquard_common::CowStr<'a>>>,
::core::option::Option<crate::app_greengale::blog::Theme<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::UriValue<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Document<'a> {
pub fn new() -> DocumentBuilder<'a, document_state::Empty> {
DocumentBuilder::new()
}
}
impl<'a> DocumentBuilder<'a, document_state::Empty> {
pub fn new() -> Self {
DocumentBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn blobs(
mut self,
value: impl Into<Option<Vec<crate::app_greengale::blog::BlobMetadata<'a>>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_blobs(
mut self,
value: Option<Vec<crate::app_greengale::blog::BlobMetadata<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> DocumentBuilder<'a, S>
where
S: document_state::State,
S::Content: document_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> DocumentBuilder<'a, document_state::SetContent<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
DocumentBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn latex(mut self, value: impl Into<Option<bool>>) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_latex(mut self, value: Option<bool>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn ogp(
mut self,
value: impl Into<Option<crate::app_greengale::blog::Ogp<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_ogp(
mut self,
value: Option<crate::app_greengale::blog::Ogp<'a>>,
) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> DocumentBuilder<'a, S>
where
S: document_state::State,
S::Path: document_state::IsUnset,
{
pub fn path(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> DocumentBuilder<'a, document_state::SetPath<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
DocumentBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> DocumentBuilder<'a, S>
where
S: document_state::State,
S::PublishedAt: document_state::IsUnset,
{
pub fn published_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> DocumentBuilder<'a, document_state::SetPublishedAt<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
DocumentBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn subtitle(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.6 = value.into();
self
}
pub fn maybe_subtitle(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.6 = value;
self
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn tags(
mut self,
value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
) -> Self {
self.__unsafe_private_named.7 = value.into();
self
}
pub fn maybe_tags(
mut self,
value: Option<Vec<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.7 = value;
self
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn theme(
mut self,
value: impl Into<Option<crate::app_greengale::blog::Theme<'a>>>,
) -> Self {
self.__unsafe_private_named.8 = value.into();
self
}
pub fn maybe_theme(
mut self,
value: Option<crate::app_greengale::blog::Theme<'a>>,
) -> Self {
self.__unsafe_private_named.8 = value;
self
}
}
impl<'a, S> DocumentBuilder<'a, S>
where
S: document_state::State,
S::Title: document_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> DocumentBuilder<'a, document_state::SetTitle<S>> {
self.__unsafe_private_named.9 = ::core::option::Option::Some(value.into());
DocumentBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> DocumentBuilder<'a, S>
where
S: document_state::State,
S::Url: document_state::IsUnset,
{
pub fn url(
mut self,
value: impl Into<jacquard_common::types::string::UriValue<'a>>,
) -> DocumentBuilder<'a, document_state::SetUrl<S>> {
self.__unsafe_private_named.10 = ::core::option::Option::Some(value.into());
DocumentBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: document_state::State> DocumentBuilder<'a, S> {
pub fn visibility(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.11 = value.into();
self
}
pub fn maybe_visibility(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.11 = value;
self
}
}
impl<'a, S> DocumentBuilder<'a, S>
where
S: document_state::State,
S::PublishedAt: document_state::IsSet,
S::Title: document_state::IsSet,
S::Url: document_state::IsSet,
S::Content: document_state::IsSet,
S::Path: document_state::IsSet,
{
pub fn build(self) -> Document<'a> {
Document {
blobs: self.__unsafe_private_named.0,
content: self.__unsafe_private_named.1.unwrap(),
latex: self.__unsafe_private_named.2.or_else(|| Some(false)),
ogp: self.__unsafe_private_named.3,
path: self.__unsafe_private_named.4.unwrap(),
published_at: self.__unsafe_private_named.5.unwrap(),
subtitle: self.__unsafe_private_named.6,
tags: self.__unsafe_private_named.7,
theme: self.__unsafe_private_named.8,
title: self.__unsafe_private_named.9.unwrap(),
url: self.__unsafe_private_named.10.unwrap(),
visibility: self
.__unsafe_private_named
.11
.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>,
>,
) -> Document<'a> {
Document {
blobs: self.__unsafe_private_named.0,
content: self.__unsafe_private_named.1.unwrap(),
latex: self.__unsafe_private_named.2.or_else(|| Some(false)),
ogp: self.__unsafe_private_named.3,
path: self.__unsafe_private_named.4.unwrap(),
published_at: self.__unsafe_private_named.5.unwrap(),
subtitle: self.__unsafe_private_named.6,
tags: self.__unsafe_private_named.7,
theme: self.__unsafe_private_named.8,
title: self.__unsafe_private_named.9.unwrap(),
url: self.__unsafe_private_named.10.unwrap(),
visibility: self
.__unsafe_private_named
.11
.or_else(|| Some(jacquard_common::CowStr::from("public"))),
extra_data: Some(extra_data),
}
}
}
impl<'a> Document<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, DocumentRecord>,
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 DocumentGetRecordOutput<'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: Document<'a>,
}
impl From<DocumentGetRecordOutput<'_>> for Document<'_> {
fn from(output: DocumentGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Document<'_> {
const NSID: &'static str = "app.greengale.document";
type Record = DocumentRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct DocumentRecord;
impl jacquard_common::xrpc::XrpcResp for DocumentRecord {
const NSID: &'static str = "app.greengale.document";
const ENCODING: &'static str = "application/json";
type Output<'de> = DocumentGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for DocumentRecord {
const NSID: &'static str = "app.greengale.document";
type Record = DocumentRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Document<'a> {
fn nsid() -> &'static str {
"app.greengale.document"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_app_greengale_document()
}
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()),
});
}
}
{
let value = &self.path;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"path",
),
max: 500usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.subtitle {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"subtitle",
),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.tags {
#[allow(unused_comparisons)]
if value.len() > 100usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"tags",
),
max: 100usize,
actual: value.len(),
});
}
}
{
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()),
});
}
}
{
let value = &self.url;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2048usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"url",
),
max: 2048usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.visibility {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 16usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"visibility",
),
max: 16usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}