#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Entry<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub authors: std::option::Option<Vec<crate::sh_weaver::actor::Author<'a>>>,
#[serde(borrow)]
pub content: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub content_warnings: std::option::Option<
crate::sh_weaver::notebook::ContentWarnings<'a>,
>,
pub created_at: jacquard_common::types::string::Datetime,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub embeds: std::option::Option<EntryEmbeds<'a>>,
#[serde(borrow)]
pub path: crate::sh_weaver::notebook::Path<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub rating: std::option::Option<crate::sh_weaver::notebook::ContentRating<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub tags: std::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
#[serde(borrow)]
pub title: crate::sh_weaver::notebook::Title<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub updated_at: std::option::Option<jacquard_common::types::string::Datetime>,
}
pub mod entry_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;
type Path;
type Content;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Title = Unset;
type Path = Unset;
type Content = 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;
type Path = S::Path;
type Content = S::Content;
}
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>;
type Path = S::Path;
type Content = S::Content;
}
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 CreatedAt = S::CreatedAt;
type Title = S::Title;
type Path = Set<members::path>;
type Content = S::Content;
}
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 CreatedAt = S::CreatedAt;
type Title = S::Title;
type Path = S::Path;
type Content = Set<members::content>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct title(());
pub struct path(());
pub struct content(());
}
}
pub struct EntryBuilder<'a, S: entry_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<crate::sh_weaver::actor::Author<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<crate::sh_weaver::notebook::ContentWarnings<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<EntryEmbeds<'a>>,
::core::option::Option<crate::sh_weaver::notebook::Path<'a>>,
::core::option::Option<crate::sh_weaver::notebook::ContentRating<'a>>,
::core::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
::core::option::Option<crate::sh_weaver::notebook::Title<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Entry<'a> {
pub fn new() -> EntryBuilder<'a, entry_state::Empty> {
EntryBuilder::new()
}
}
impl<'a> EntryBuilder<'a, entry_state::Empty> {
pub fn new() -> Self {
EntryBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: entry_state::State> EntryBuilder<'a, S> {
pub fn authors(
mut self,
value: impl Into<Option<Vec<crate::sh_weaver::actor::Author<'a>>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_authors(
mut self,
value: Option<Vec<crate::sh_weaver::actor::Author<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> EntryBuilder<'a, S>
where
S: entry_state::State,
S::Content: entry_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> EntryBuilder<'a, entry_state::SetContent<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
EntryBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: entry_state::State> EntryBuilder<'a, S> {
pub fn content_warnings(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::ContentWarnings<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_content_warnings(
mut self,
value: Option<crate::sh_weaver::notebook::ContentWarnings<'a>>,
) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S> EntryBuilder<'a, S>
where
S: entry_state::State,
S::CreatedAt: entry_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> EntryBuilder<'a, entry_state::SetCreatedAt<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
EntryBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: entry_state::State> EntryBuilder<'a, S> {
pub fn embeds(mut self, value: impl Into<Option<EntryEmbeds<'a>>>) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_embeds(mut self, value: Option<EntryEmbeds<'a>>) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S> EntryBuilder<'a, S>
where
S: entry_state::State,
S::Path: entry_state::IsUnset,
{
pub fn path(
mut self,
value: impl Into<crate::sh_weaver::notebook::Path<'a>>,
) -> EntryBuilder<'a, entry_state::SetPath<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
EntryBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: entry_state::State> EntryBuilder<'a, S> {
pub fn rating(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::ContentRating<'a>>>,
) -> Self {
self.__unsafe_private_named.6 = value.into();
self
}
pub fn maybe_rating(
mut self,
value: Option<crate::sh_weaver::notebook::ContentRating<'a>>,
) -> Self {
self.__unsafe_private_named.6 = value;
self
}
}
impl<'a, S: entry_state::State> EntryBuilder<'a, S> {
pub fn tags(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::Tags<'a>>>,
) -> Self {
self.__unsafe_private_named.7 = value.into();
self
}
pub fn maybe_tags(
mut self,
value: Option<crate::sh_weaver::notebook::Tags<'a>>,
) -> Self {
self.__unsafe_private_named.7 = value;
self
}
}
impl<'a, S> EntryBuilder<'a, S>
where
S: entry_state::State,
S::Title: entry_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<crate::sh_weaver::notebook::Title<'a>>,
) -> EntryBuilder<'a, entry_state::SetTitle<S>> {
self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
EntryBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: entry_state::State> EntryBuilder<'a, S> {
pub fn updated_at(
mut self,
value: impl Into<Option<jacquard_common::types::string::Datetime>>,
) -> Self {
self.__unsafe_private_named.9 = value.into();
self
}
pub fn maybe_updated_at(
mut self,
value: Option<jacquard_common::types::string::Datetime>,
) -> Self {
self.__unsafe_private_named.9 = value;
self
}
}
impl<'a, S> EntryBuilder<'a, S>
where
S: entry_state::State,
S::CreatedAt: entry_state::IsSet,
S::Title: entry_state::IsSet,
S::Path: entry_state::IsSet,
S::Content: entry_state::IsSet,
{
pub fn build(self) -> Entry<'a> {
Entry {
authors: self.__unsafe_private_named.0,
content: self.__unsafe_private_named.1.unwrap(),
content_warnings: self.__unsafe_private_named.2,
created_at: self.__unsafe_private_named.3.unwrap(),
embeds: self.__unsafe_private_named.4,
path: self.__unsafe_private_named.5.unwrap(),
rating: self.__unsafe_private_named.6,
tags: self.__unsafe_private_named.7,
title: self.__unsafe_private_named.8.unwrap(),
updated_at: self.__unsafe_private_named.9,
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>,
>,
) -> Entry<'a> {
Entry {
authors: self.__unsafe_private_named.0,
content: self.__unsafe_private_named.1.unwrap(),
content_warnings: self.__unsafe_private_named.2,
created_at: self.__unsafe_private_named.3.unwrap(),
embeds: self.__unsafe_private_named.4,
path: self.__unsafe_private_named.5.unwrap(),
rating: self.__unsafe_private_named.6,
tags: self.__unsafe_private_named.7,
title: self.__unsafe_private_named.8.unwrap(),
updated_at: self.__unsafe_private_named.9,
extra_data: Some(extra_data),
}
}
}
impl<'a> Entry<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, EntryRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic,
Default
)]
#[serde(rename_all = "camelCase")]
pub struct EntryEmbeds<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub externals: std::option::Option<crate::sh_weaver::embed::external::External<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub images: std::option::Option<crate::sh_weaver::embed::images::Images<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub records: std::option::Option<crate::sh_weaver::embed::records::Records<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub records_with_media: std::option::Option<
Vec<crate::sh_weaver::embed::record_with_media::RecordWithMedia<'a>>,
>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub videos: std::option::Option<crate::sh_weaver::embed::video::VideoRecord<'a>>,
}
fn lexicon_doc_sh_weaver_notebook_entry() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.entry"),
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("A notebook entry"),
),
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("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("path"),
::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(
"authors",
),
::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(
"sh.weaver.actor.defs#author",
),
}),
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(
"The content of the notebook entry. This should be some flavor of Markdown.",
),
),
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.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"contentWarnings",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#contentWarnings",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Client-declared timestamp when this was originally created.",
),
),
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(
"embeds",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static(
"The set of images and records, if any, embedded in the notebook entry.",
),
),
required: None,
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"externals",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.embed.external",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"images",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.embed.images",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"records",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.embed.records",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"recordsWithMedia",
),
::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(
"sh.weaver.embed.recordWithMedia",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"videos",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.embed.video",
),
}),
);
map
},
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"path",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#path",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"rating",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#contentRating",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"tags",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#tags",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"title",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#title",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"updatedAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Client-declared timestamp of last modification. Used for canonicality tiebreaking in multi-author scenarios.",
),
),
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
},
}),
}),
);
map
},
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for EntryEmbeds<'a> {
fn nsid() -> &'static str {
"sh.weaver.notebook.entry"
}
fn def_name() -> &'static str {
"EntryEmbeds"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_entry()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct EntryGetRecordOutput<'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: Entry<'a>,
}
impl From<EntryGetRecordOutput<'_>> for Entry<'_> {
fn from(output: EntryGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Entry<'_> {
const NSID: &'static str = "sh.weaver.notebook.entry";
type Record = EntryRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct EntryRecord;
impl jacquard_common::xrpc::XrpcResp for EntryRecord {
const NSID: &'static str = "sh.weaver.notebook.entry";
const ENCODING: &'static str = "application/json";
type Output<'de> = EntryGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for EntryRecord {
const NSID: &'static str = "sh.weaver.notebook.entry";
type Record = EntryRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Entry<'a> {
fn nsid() -> &'static str {
"sh.weaver.notebook.entry"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_entry()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}