#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Videos<'a> {
#[serde(borrow)]
pub creator: jacquard_common::types::string::Did<'a>,
#[serde(borrow)]
pub id: jacquard_common::types::value::Data<'a>,
#[serde(borrow)]
pub title: jacquard_common::CowStr<'a>,
}
pub mod videos_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 Id;
type Title;
type Creator;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type Title = Unset;
type Creator = Unset;
}
pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetId<S> {}
impl<S: State> State for SetId<S> {
type Id = Set<members::id>;
type Title = S::Title;
type Creator = S::Creator;
}
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 Id = S::Id;
type Title = Set<members::title>;
type Creator = S::Creator;
}
pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreator<S> {}
impl<S: State> State for SetCreator<S> {
type Id = S::Id;
type Title = S::Title;
type Creator = Set<members::creator>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct title(());
pub struct creator(());
}
}
pub struct VideosBuilder<'a, S: videos_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Did<'a>>,
::core::option::Option<jacquard_common::types::value::Data<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Videos<'a> {
pub fn new() -> VideosBuilder<'a, videos_state::Empty> {
VideosBuilder::new()
}
}
impl<'a> VideosBuilder<'a, videos_state::Empty> {
pub fn new() -> Self {
VideosBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> VideosBuilder<'a, S>
where
S: videos_state::State,
S::Creator: videos_state::IsUnset,
{
pub fn creator(
mut self,
value: impl Into<jacquard_common::types::string::Did<'a>>,
) -> VideosBuilder<'a, videos_state::SetCreator<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
VideosBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> VideosBuilder<'a, S>
where
S: videos_state::State,
S::Id: videos_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<jacquard_common::types::value::Data<'a>>,
) -> VideosBuilder<'a, videos_state::SetId<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
VideosBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> VideosBuilder<'a, S>
where
S: videos_state::State,
S::Title: videos_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> VideosBuilder<'a, videos_state::SetTitle<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
VideosBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> VideosBuilder<'a, S>
where
S: videos_state::State,
S::Id: videos_state::IsSet,
S::Title: videos_state::IsSet,
S::Creator: videos_state::IsSet,
{
pub fn build(self) -> Videos<'a> {
Videos {
creator: self.__unsafe_private_named.0.unwrap(),
id: self.__unsafe_private_named.1.unwrap(),
title: self.__unsafe_private_named.2.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>,
>,
) -> Videos<'a> {
Videos {
creator: self.__unsafe_private_named.0.unwrap(),
id: self.__unsafe_private_named.1.unwrap(),
title: self.__unsafe_private_named.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> Videos<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, VideosRecord>,
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 VideosGetRecordOutput<'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: Videos<'a>,
}
impl From<VideosGetRecordOutput<'_>> for Videos<'_> {
fn from(output: VideosGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Videos<'_> {
const NSID: &'static str = "com.5jiji.test.videos";
type Record = VideosRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct VideosRecord;
impl jacquard_common::xrpc::XrpcResp for VideosRecord {
const NSID: &'static str = "com.5jiji.test.videos";
const ENCODING: &'static str = "application/json";
type Output<'de> = VideosGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for VideosRecord {
const NSID: &'static str = "com.5jiji.test.videos";
type Record = VideosRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Videos<'a> {
fn nsid() -> &'static str {
"com.5jiji.test.videos"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_com_5jiji_test_videos()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.title;
{
let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes(
value.as_ref(),
true,
)
.count();
if count > 150usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"title",
),
max: 150usize,
actual: count,
});
}
}
}
Ok(())
}
}
fn lexicon_doc_com_5jiji_test_videos() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("com.5jiji.test.videos"),
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 video")),
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("id"),
::jacquard_common::deps::smol_str::SmolStr::new_static("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("creator")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"creator",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Did,
),
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(
"id",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"com.5jiji.test.vidId",
),
}),
);
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: None,
min_graphemes: None,
max_graphemes: Some(150usize),
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}