#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct TestingPolisStatementV1<'a> {
pub created_at: jacquard_common::types::string::Datetime,
#[serde(borrow)]
pub poll: crate::scot_comhairle::testing_polis_statement_v1::PollRef<'a>,
#[serde(borrow)]
pub text: jacquard_common::CowStr<'a>,
}
pub mod testing_polis_statement_v1_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 Text;
type Poll;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Text = Unset;
type Poll = 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 Text = S::Text;
type Poll = S::Poll;
}
pub struct SetText<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetText<S> {}
impl<S: State> State for SetText<S> {
type CreatedAt = S::CreatedAt;
type Text = Set<members::text>;
type Poll = S::Poll;
}
pub struct SetPoll<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPoll<S> {}
impl<S: State> State for SetPoll<S> {
type CreatedAt = S::CreatedAt;
type Text = S::Text;
type Poll = Set<members::poll>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct text(());
pub struct poll(());
}
}
pub struct TestingPolisStatementV1Builder<
'a,
S: testing_polis_statement_v1_state::State,
> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<
crate::scot_comhairle::testing_polis_statement_v1::PollRef<'a>,
>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> TestingPolisStatementV1<'a> {
pub fn new() -> TestingPolisStatementV1Builder<
'a,
testing_polis_statement_v1_state::Empty,
> {
TestingPolisStatementV1Builder::new()
}
}
impl<'a> TestingPolisStatementV1Builder<'a, testing_polis_statement_v1_state::Empty> {
pub fn new() -> Self {
TestingPolisStatementV1Builder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TestingPolisStatementV1Builder<'a, S>
where
S: testing_polis_statement_v1_state::State,
S::CreatedAt: testing_polis_statement_v1_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> TestingPolisStatementV1Builder<
'a,
testing_polis_statement_v1_state::SetCreatedAt<S>,
> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
TestingPolisStatementV1Builder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TestingPolisStatementV1Builder<'a, S>
where
S: testing_polis_statement_v1_state::State,
S::Poll: testing_polis_statement_v1_state::IsUnset,
{
pub fn poll(
mut self,
value: impl Into<crate::scot_comhairle::testing_polis_statement_v1::PollRef<'a>>,
) -> TestingPolisStatementV1Builder<
'a,
testing_polis_statement_v1_state::SetPoll<S>,
> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
TestingPolisStatementV1Builder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TestingPolisStatementV1Builder<'a, S>
where
S: testing_polis_statement_v1_state::State,
S::Text: testing_polis_statement_v1_state::IsUnset,
{
pub fn text(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> TestingPolisStatementV1Builder<
'a,
testing_polis_statement_v1_state::SetText<S>,
> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
TestingPolisStatementV1Builder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> TestingPolisStatementV1Builder<'a, S>
where
S: testing_polis_statement_v1_state::State,
S::CreatedAt: testing_polis_statement_v1_state::IsSet,
S::Text: testing_polis_statement_v1_state::IsSet,
S::Poll: testing_polis_statement_v1_state::IsSet,
{
pub fn build(self) -> TestingPolisStatementV1<'a> {
TestingPolisStatementV1 {
created_at: self.__unsafe_private_named.0.unwrap(),
poll: self.__unsafe_private_named.1.unwrap(),
text: 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>,
>,
) -> TestingPolisStatementV1<'a> {
TestingPolisStatementV1 {
created_at: self.__unsafe_private_named.0.unwrap(),
poll: self.__unsafe_private_named.1.unwrap(),
text: self.__unsafe_private_named.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> TestingPolisStatementV1<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, TestingPolisStatementV1Record>,
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 TestingPolisStatementV1GetRecordOutput<'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: TestingPolisStatementV1<'a>,
}
impl From<TestingPolisStatementV1GetRecordOutput<'_>> for TestingPolisStatementV1<'_> {
fn from(output: TestingPolisStatementV1GetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for TestingPolisStatementV1<'_> {
const NSID: &'static str = "scot.comhairle.testingPolisStatementV1";
type Record = TestingPolisStatementV1Record;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TestingPolisStatementV1Record;
impl jacquard_common::xrpc::XrpcResp for TestingPolisStatementV1Record {
const NSID: &'static str = "scot.comhairle.testingPolisStatementV1";
const ENCODING: &'static str = "application/json";
type Output<'de> = TestingPolisStatementV1GetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for TestingPolisStatementV1Record {
const NSID: &'static str = "scot.comhairle.testingPolisStatementV1";
type Record = TestingPolisStatementV1Record;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for TestingPolisStatementV1<'a> {
fn nsid() -> &'static str {
"scot.comhairle.testingPolisStatementV1"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_scot_comhairle_testingPolisStatementV1()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"text",
),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_scot_comhairle_testingPolisStatementV1() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static(
"scot.comhairle.testingPolisStatementV1",
),
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 statement in the Polis-style deliberation system",
),
),
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("text"),
::jacquard_common::deps::smol_str::SmolStr::new_static("poll"),
::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(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Timestamp when the statement was 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(
"poll",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static("#pollRef"),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"text",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The text content of the statement",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(3000usize),
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("pollRef"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static(
"Reference to a poll record",
),
),
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("uri"),
::jacquard_common::deps::smol_str::SmolStr::new_static("cid")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"cid",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Content identifier of the poll record",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Cid,
),
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(
"uri",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"AT-URI of the poll record",
),
),
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
},
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct PollRef<'a> {
#[serde(borrow)]
pub cid: jacquard_common::types::string::Cid<'a>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
}
pub mod poll_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;
type Cid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Cid = 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>;
type Cid = S::Cid;
}
pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCid<S> {}
impl<S: State> State for SetCid<S> {
type Uri = S::Uri;
type Cid = Set<members::cid>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct cid(());
}
}
pub struct PollRefBuilder<'a, S: poll_ref_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Cid<'a>>,
::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> PollRef<'a> {
pub fn new() -> PollRefBuilder<'a, poll_ref_state::Empty> {
PollRefBuilder::new()
}
}
impl<'a> PollRefBuilder<'a, poll_ref_state::Empty> {
pub fn new() -> Self {
PollRefBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PollRefBuilder<'a, S>
where
S: poll_ref_state::State,
S::Cid: poll_ref_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<jacquard_common::types::string::Cid<'a>>,
) -> PollRefBuilder<'a, poll_ref_state::SetCid<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
PollRefBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PollRefBuilder<'a, S>
where
S: poll_ref_state::State,
S::Uri: poll_ref_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<jacquard_common::types::string::AtUri<'a>>,
) -> PollRefBuilder<'a, poll_ref_state::SetUri<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
PollRefBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> PollRefBuilder<'a, S>
where
S: poll_ref_state::State,
S::Uri: poll_ref_state::IsSet,
S::Cid: poll_ref_state::IsSet,
{
pub fn build(self) -> PollRef<'a> {
PollRef {
cid: self.__unsafe_private_named.0.unwrap(),
uri: self.__unsafe_private_named.1.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>,
>,
) -> PollRef<'a> {
PollRef {
cid: self.__unsafe_private_named.0.unwrap(),
uri: self.__unsafe_private_named.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for PollRef<'a> {
fn nsid() -> &'static str {
"scot.comhairle.testingPolisStatementV1"
}
fn def_name() -> &'static str {
"pollRef"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_scot_comhairle_testingPolisStatementV1()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}