#[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, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::richtext::facet::Facet;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::org_hypercerts::SmallImage;
use crate::org_hypercerts::Uri;
use crate::org_hypercerts::workscope::cel::Cel;
use crate::pub_leaflet::pages::linear_document::LinearDocument;
use crate::org_hypercerts::claim::activity;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Contributor<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub contribution_details: Option<ContributorContributionDetails<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub contribution_weight: Option<CowStr<'a>>,
#[serde(borrow)]
pub contributor_identity: ContributorContributorIdentity<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ContributorContributionDetails<'a> {
#[serde(rename = "org.hypercerts.claim.activity#contributorRole")]
ContributorRole(Box<activity::ContributorRole<'a>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<'a>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ContributorContributorIdentity<'a> {
#[serde(rename = "org.hypercerts.claim.activity#contributorIdentity")]
ContributorIdentity(Box<activity::ContributorIdentity<'a>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ContributorIdentity<'a> {
#[serde(borrow)]
pub identity: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ContributorRole<'a> {
#[serde(borrow)]
pub role: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Activity<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub contributors: Option<Vec<activity::Contributor<'a>>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<LinearDocument<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub end_date: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub image: Option<ActivityImage<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub locations: Option<Vec<StrongRef<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub rights: Option<StrongRef<'a>>,
#[serde(borrow)]
pub short_description: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub short_description_facets: Option<Vec<Facet<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub start_date: Option<Datetime>,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub work_scope: Option<ActivityWorkScope<'a>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ActivityImage<'a> {
#[serde(rename = "org.hypercerts.defs#uri")]
Uri(Box<Uri<'a>>),
#[serde(rename = "org.hypercerts.defs#smallImage")]
SmallImage(Box<SmallImage<'a>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ActivityWorkScope<'a> {
#[serde(rename = "org.hypercerts.workscope.cel")]
Cel(Box<Cel<'a>>),
#[serde(rename = "org.hypercerts.claim.activity#workScopeString")]
WorkScopeString(Box<activity::WorkScopeString<'a>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ActivityGetRecordOutput<'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: Activity<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct WorkScopeString<'a> {
#[serde(borrow)]
pub scope: CowStr<'a>,
}
impl<'a> Activity<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, ActivityRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for Contributor<'a> {
fn nsid() -> &'static str {
"org.hypercerts.claim.activity"
}
fn def_name() -> &'static str {
"contributor"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_claim_activity()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.contribution_weight {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("contribution_weight"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ContributorIdentity<'a> {
fn nsid() -> &'static str {
"org.hypercerts.claim.activity"
}
fn def_name() -> &'static str {
"contributorIdentity"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_claim_activity()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.identity;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("identity"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.identity;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 100usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("identity"),
max: 100usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ContributorRole<'a> {
fn nsid() -> &'static str {
"org.hypercerts.claim.activity"
}
fn def_name() -> &'static str {
"contributorRole"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_claim_activity()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.role;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("role"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.role;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 100usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("role"),
max: 100usize,
actual: count,
});
}
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ActivityRecord;
impl XrpcResp for ActivityRecord {
const NSID: &'static str = "org.hypercerts.claim.activity";
const ENCODING: &'static str = "application/json";
type Output<'de> = ActivityGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<ActivityGetRecordOutput<'_>> for Activity<'_> {
fn from(output: ActivityGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Activity<'_> {
const NSID: &'static str = "org.hypercerts.claim.activity";
type Record = ActivityRecord;
}
impl Collection for ActivityRecord {
const NSID: &'static str = "org.hypercerts.claim.activity";
type Record = ActivityRecord;
}
impl<'a> LexiconSchema for Activity<'a> {
fn nsid() -> &'static str {
"org.hypercerts.claim.activity"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_claim_activity()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.contributors {
#[allow(unused_comparisons)]
if value.len() > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("contributors"),
max: 1000usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.locations {
#[allow(unused_comparisons)]
if value.len() > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("locations"),
max: 1000usize,
actual: value.len(),
});
}
}
{
let value = &self.short_description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("short_description"),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.short_description;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 300usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("short_description"),
max: 300usize,
actual: count,
});
}
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for WorkScopeString<'a> {
fn nsid() -> &'static str {
"org.hypercerts.claim.activity"
}
fn def_name() -> &'static str {
"workScopeString"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_hypercerts_claim_activity()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.scope;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("scope"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.scope;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 100usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("scope"),
max: 100usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod contributor_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 ContributorIdentity;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ContributorIdentity = Unset;
}
pub struct SetContributorIdentity<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContributorIdentity<S> {}
impl<S: State> State for SetContributorIdentity<S> {
type ContributorIdentity = Set<members::contributor_identity>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct contributor_identity(());
}
}
pub struct ContributorBuilder<'a, S: contributor_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ContributorContributionDetails<'a>>,
Option<CowStr<'a>>,
Option<ContributorContributorIdentity<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Contributor<'a> {
pub fn new() -> ContributorBuilder<'a, contributor_state::Empty> {
ContributorBuilder::new()
}
}
impl<'a> ContributorBuilder<'a, contributor_state::Empty> {
pub fn new() -> Self {
ContributorBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: contributor_state::State> ContributorBuilder<'a, S> {
pub fn contribution_details(
mut self,
value: impl Into<Option<ContributorContributionDetails<'a>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_contribution_details(
mut self,
value: Option<ContributorContributionDetails<'a>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: contributor_state::State> ContributorBuilder<'a, S> {
pub fn contribution_weight(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_contribution_weight(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> ContributorBuilder<'a, S>
where
S: contributor_state::State,
S::ContributorIdentity: contributor_state::IsUnset,
{
pub fn contributor_identity(
mut self,
value: impl Into<ContributorContributorIdentity<'a>>,
) -> ContributorBuilder<'a, contributor_state::SetContributorIdentity<S>> {
self._fields.2 = Option::Some(value.into());
ContributorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ContributorBuilder<'a, S>
where
S: contributor_state::State,
S::ContributorIdentity: contributor_state::IsSet,
{
pub fn build(self) -> Contributor<'a> {
Contributor {
contribution_details: self._fields.0,
contribution_weight: self._fields.1,
contributor_identity: self._fields.2.unwrap(),
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>,
>,
) -> Contributor<'a> {
Contributor {
contribution_details: self._fields.0,
contribution_weight: self._fields.1,
contributor_identity: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_hypercerts_claim_activity() -> 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.hypercerts.claim.activity"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("contributor"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("contributorIdentity")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("contributionDetails"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Inline contribution role object with a role string via org.hypercerts.claim.activity#contributorRole, or a strong reference to a contribution details record. The record referenced must conform with the lexicon org.hypercerts.claim.contribution.",
),
),
refs: vec![
CowStr::new_static("#contributorRole"),
CowStr::new_static("com.atproto.repo.strongRef")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contributionWeight"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The relative weight/importance of this contribution (stored as a string to avoid float precision issues). Must be a positive numeric value. Weights do not need to sum to a specific total; normalization can be performed by the consuming application as needed.",
),
),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contributorIdentity"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Inline contributor identity object with an identity string (DID or identifier) via org.hypercerts.claim.activity#contributorIdentity, or a strong reference to a contributor information record. The record referenced must conform with the lexicon org.hypercerts.claim.contributorInformation.",
),
),
refs: vec![
CowStr::new_static("#contributorIdentity"),
CowStr::new_static("com.atproto.repo.strongRef")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contributorIdentity"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Contributor information as a string (DID or identifier).",
),
),
required: Some(vec![SmolStr::new_static("identity")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("identity"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The contributor identity string (DID or identifier).",
),
),
max_length: Some(1000usize),
max_graphemes: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contributorRole"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Contribution details as a string."),
),
required: Some(vec![SmolStr::new_static("role")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("role"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The contribution role or details."),
),
max_length: Some(1000usize),
max_graphemes: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("A hypercert record tracking impact work."),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("title"),
SmolStr::new_static("shortDescription"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("contributors"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"An array of contributor objects, each containing contributor information, weight, and contribution details.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#contributor"),
..Default::default()
}),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Client-declared timestamp when this record was originally created",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"pub.leaflet.pages.linearDocument#main",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("endDate"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the work ended"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("image"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"The hypercert visual representation as a URI or image blob.",
),
),
refs: vec![
CowStr::new_static("org.hypercerts.defs#uri"),
CowStr::new_static("org.hypercerts.defs#smallImage")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("locations"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"An array of strong references to the location where activity was performed. The record referenced must conform with the lexicon app.certified.location.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rights"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("shortDescription"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Short summary of this activity claim, suitable for previews and list views. Rich text annotations may be provided via `shortDescriptionFacets`.",
),
),
max_length: Some(3000usize),
max_graphemes: Some(300usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("shortDescriptionFacets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Rich text annotations for `shortDescription` (mentions, URLs, hashtags, etc).",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("app.bsky.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startDate"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the work began"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Display title summarizing the impact work (e.g. 'Reforestation in Amazon Basin 2024')",
),
),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("workScope"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Work scope definition. A CEL expression for structured, machine-evaluable scopes or a free-form string for simple and legacy scopes.",
),
),
refs: vec![
CowStr::new_static("org.hypercerts.workscope.cel"),
CowStr::new_static("#workScopeString")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("workScopeString"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A free-form string describing the work scope for simple or legacy scopes.",
),
),
required: Some(vec![SmolStr::new_static("scope")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("scope"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The work scope description string."),
),
max_length: Some(1000usize),
max_graphemes: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod activity_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 Title;
type CreatedAt;
type ShortDescription;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Title = Unset;
type CreatedAt = Unset;
type ShortDescription = Unset;
}
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 Title = Set<members::title>;
type CreatedAt = S::CreatedAt;
type ShortDescription = S::ShortDescription;
}
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 Title = S::Title;
type CreatedAt = Set<members::created_at>;
type ShortDescription = S::ShortDescription;
}
pub struct SetShortDescription<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetShortDescription<S> {}
impl<S: State> State for SetShortDescription<S> {
type Title = S::Title;
type CreatedAt = S::CreatedAt;
type ShortDescription = Set<members::short_description>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct title(());
pub struct created_at(());
pub struct short_description(());
}
}
pub struct ActivityBuilder<'a, S: activity_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<activity::Contributor<'a>>>,
Option<Datetime>,
Option<LinearDocument<'a>>,
Option<Datetime>,
Option<ActivityImage<'a>>,
Option<Vec<StrongRef<'a>>>,
Option<StrongRef<'a>>,
Option<CowStr<'a>>,
Option<Vec<Facet<'a>>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<ActivityWorkScope<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Activity<'a> {
pub fn new() -> ActivityBuilder<'a, activity_state::Empty> {
ActivityBuilder::new()
}
}
impl<'a> ActivityBuilder<'a, activity_state::Empty> {
pub fn new() -> Self {
ActivityBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn contributors(
mut self,
value: impl Into<Option<Vec<activity::Contributor<'a>>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_contributors(
mut self,
value: Option<Vec<activity::Contributor<'a>>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::CreatedAt: activity_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ActivityBuilder<'a, activity_state::SetCreatedAt<S>> {
self._fields.1 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<LinearDocument<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<LinearDocument<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn end_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_end_date(mut self, value: Option<Datetime>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn image(mut self, value: impl Into<Option<ActivityImage<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_image(mut self, value: Option<ActivityImage<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn locations(mut self, value: impl Into<Option<Vec<StrongRef<'a>>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_locations(mut self, value: Option<Vec<StrongRef<'a>>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn rights(mut self, value: impl Into<Option<StrongRef<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_rights(mut self, value: Option<StrongRef<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::ShortDescription: activity_state::IsUnset,
{
pub fn short_description(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActivityBuilder<'a, activity_state::SetShortDescription<S>> {
self._fields.7 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn short_description_facets(
mut self,
value: impl Into<Option<Vec<Facet<'a>>>>,
) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_short_description_facets(
mut self,
value: Option<Vec<Facet<'a>>>,
) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn start_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_start_date(mut self, value: Option<Datetime>) -> Self {
self._fields.9 = value;
self
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::Title: activity_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActivityBuilder<'a, activity_state::SetTitle<S>> {
self._fields.10 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: activity_state::State> ActivityBuilder<'a, S> {
pub fn work_scope(
mut self,
value: impl Into<Option<ActivityWorkScope<'a>>>,
) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_work_scope(mut self, value: Option<ActivityWorkScope<'a>>) -> Self {
self._fields.11 = value;
self
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::Title: activity_state::IsSet,
S::CreatedAt: activity_state::IsSet,
S::ShortDescription: activity_state::IsSet,
{
pub fn build(self) -> Activity<'a> {
Activity {
contributors: self._fields.0,
created_at: self._fields.1.unwrap(),
description: self._fields.2,
end_date: self._fields.3,
image: self._fields.4,
locations: self._fields.5,
rights: self._fields.6,
short_description: self._fields.7.unwrap(),
short_description_facets: self._fields.8,
start_date: self._fields.9,
title: self._fields.10.unwrap(),
work_scope: self._fields.11,
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>,
>,
) -> Activity<'a> {
Activity {
contributors: self._fields.0,
created_at: self._fields.1.unwrap(),
description: self._fields.2,
end_date: self._fields.3,
image: self._fields.4,
locations: self._fields.5,
rights: self._fields.6,
short_description: self._fields.7.unwrap(),
short_description_facets: self._fields.8,
start_date: self._fields.9,
title: self._fields.10.unwrap(),
work_scope: self._fields.11,
extra_data: Some(extra_data),
}
}
}