#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Test<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
pub end: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub location: Option<CowStr<'a>>,
pub start: Datetime,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub url: Option<CowStr<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TestGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Test<'a>,
}
impl<'a> Test<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, TestRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct TestRecord;
impl XrpcResp for TestRecord {
const NSID: &'static str = "org.devcon.event.test";
const ENCODING: &'static str = "application/json";
type Output<'de> = TestGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<TestGetRecordOutput<'_>> for Test<'_> {
fn from(output: TestGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Test<'_> {
const NSID: &'static str = "org.devcon.event.test";
type Record = TestRecord;
}
impl Collection for TestRecord {
const NSID: &'static str = "org.devcon.event.test";
type Record = TestRecord;
}
impl<'a> LexiconSchema for Test<'a> {
fn nsid() -> &'static str {
"org.devcon.event.test"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_devcon_event_test()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod test_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 Start;
type End;
type Title;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Start = Unset;
type End = Unset;
type Title = Unset;
}
pub struct SetStart<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStart<S> {}
impl<S: State> State for SetStart<S> {
type Start = Set<members::start>;
type End = S::End;
type Title = S::Title;
}
pub struct SetEnd<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEnd<S> {}
impl<S: State> State for SetEnd<S> {
type Start = S::Start;
type End = Set<members::end>;
type Title = S::Title;
}
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 Start = S::Start;
type End = S::End;
type Title = Set<members::title>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct start(());
pub struct end(());
pub struct title(());
}
}
pub struct TestBuilder<'a, S: test_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Test<'a> {
pub fn new() -> TestBuilder<'a, test_state::Empty> {
TestBuilder::new()
}
}
impl<'a> TestBuilder<'a, test_state::Empty> {
pub fn new() -> Self {
TestBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: test_state::State> TestBuilder<'a, S> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: test_state::State> TestBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> TestBuilder<'a, S>
where
S: test_state::State,
S::End: test_state::IsUnset,
{
pub fn end(
mut self,
value: impl Into<Datetime>,
) -> TestBuilder<'a, test_state::SetEnd<S>> {
self._fields.2 = Option::Some(value.into());
TestBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: test_state::State> TestBuilder<'a, S> {
pub fn location(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_location(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> TestBuilder<'a, S>
where
S: test_state::State,
S::Start: test_state::IsUnset,
{
pub fn start(
mut self,
value: impl Into<Datetime>,
) -> TestBuilder<'a, test_state::SetStart<S>> {
self._fields.4 = Option::Some(value.into());
TestBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TestBuilder<'a, S>
where
S: test_state::State,
S::Title: test_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> TestBuilder<'a, test_state::SetTitle<S>> {
self._fields.5 = Option::Some(value.into());
TestBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: test_state::State> TestBuilder<'a, S> {
pub fn url(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_url(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> TestBuilder<'a, S>
where
S: test_state::State,
S::Start: test_state::IsSet,
S::End: test_state::IsSet,
S::Title: test_state::IsSet,
{
pub fn build(self) -> Test<'a> {
Test {
created_at: self._fields.0,
description: self._fields.1,
end: self._fields.2.unwrap(),
location: self._fields.3,
start: self._fields.4.unwrap(),
title: self._fields.5.unwrap(),
url: self._fields.6,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Test<'a> {
Test {
created_at: self._fields.0,
description: self._fields.1,
end: self._fields.2.unwrap(),
location: self._fields.3,
start: self._fields.4.unwrap(),
title: self._fields.5.unwrap(),
url: self._fields.6,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_devcon_event_test() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("org.devcon.event.test"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("title"), SmolStr::new_static("start"),
SmolStr::new_static("end")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Description of the event"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("end"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("End time of the event"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("location"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Location of the event"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("start"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Start time of the event"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Title of the event")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("URL of the event")),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}