#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
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::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
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::claim::activity;
use crate::org_hypercerts::workscope::cel::Cel;
use crate::pub_leaflet::pages::linear_document::LinearDocument;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Contributor<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub contribution_details: Option<ContributorContributionDetails<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub contribution_weight: Option<S>,
pub contributor_identity: ContributorContributorIdentity<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ContributorContributionDetails<S: BosStr = DefaultStr> {
#[serde(rename = "org.hypercerts.claim.activity#contributorRole")]
ContributorRole(Box<activity::ContributorRole<S>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<S>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ContributorContributorIdentity<S: BosStr = DefaultStr> {
#[serde(rename = "org.hypercerts.claim.activity#contributorIdentity")]
ContributorIdentity(Box<activity::ContributorIdentity<S>>),
#[serde(rename = "com.atproto.repo.strongRef")]
StrongRef(Box<StrongRef<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ContributorIdentity<S: BosStr = DefaultStr> {
pub identity: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ContributorRole<S: BosStr = DefaultStr> {
pub role: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "org.hypercerts.claim.activity",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Activity<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub contributors: Option<Vec<activity::Contributor<S>>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<LinearDocument<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub end_date: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub image: Option<ActivityImage<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub locations: Option<Vec<StrongRef<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rights: Option<StrongRef<S>>,
pub short_description: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub short_description_facets: Option<Vec<Facet<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub start_date: Option<Datetime>,
pub title: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub work_scope: Option<ActivityWorkScope<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ActivityImage<S: BosStr = DefaultStr> {
#[serde(rename = "org.hypercerts.defs#uri")]
Uri(Box<Uri<S>>),
#[serde(rename = "org.hypercerts.defs#smallImage")]
SmallImage(Box<SmallImage<S>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ActivityWorkScope<S: BosStr = DefaultStr> {
#[serde(rename = "org.hypercerts.workscope.cel")]
Cel(Box<Cel<S>>),
#[serde(rename = "org.hypercerts.claim.activity#workScopeString")]
WorkScopeString(Box<activity::WorkScopeString<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ActivityGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Activity<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct WorkScopeString<S: BosStr = DefaultStr> {
pub scope: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Activity<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, ActivityRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Contributor<S> {
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<S: BosStr> LexiconSchema for ContributorIdentity<S> {
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<S: BosStr> LexiconSchema for ContributorRole<S> {
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<S: BosStr> = ActivityGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<ActivityGetRecordOutput<S>> for Activity<S> {
fn from(output: ActivityGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Activity<S> {
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<S: BosStr> LexiconSchema for Activity<S> {
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<S: BosStr> LexiconSchema for WorkScopeString<S> {
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContributorIdentity<St> {}
impl<St: State> State for SetContributorIdentity<St> {
type ContributorIdentity = Set<members::contributor_identity>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct contributor_identity(());
}
}
pub struct ContributorBuilder<S: BosStr, St: contributor_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ContributorContributionDetails<S>>,
Option<S>,
Option<ContributorContributorIdentity<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Contributor<S> {
pub fn new() -> ContributorBuilder<S, contributor_state::Empty> {
ContributorBuilder::new()
}
}
impl<S: BosStr> ContributorBuilder<S, contributor_state::Empty> {
pub fn new() -> Self {
ContributorBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: contributor_state::State> ContributorBuilder<S, St> {
pub fn contribution_details(
mut self,
value: impl Into<Option<ContributorContributionDetails<S>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_contribution_details(
mut self,
value: Option<ContributorContributionDetails<S>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: contributor_state::State> ContributorBuilder<S, St> {
pub fn contribution_weight(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_contribution_weight(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> ContributorBuilder<S, St>
where
St: contributor_state::State,
St::ContributorIdentity: contributor_state::IsUnset,
{
pub fn contributor_identity(
mut self,
value: impl Into<ContributorContributorIdentity<S>>,
) -> ContributorBuilder<S, contributor_state::SetContributorIdentity<St>> {
self._fields.2 = Option::Some(value.into());
ContributorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ContributorBuilder<S, St>
where
St: contributor_state::State,
St::ContributorIdentity: contributor_state::IsSet,
{
pub fn build(self) -> Contributor<S> {
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<SmolStr, Data<S>>) -> Contributor<S> {
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type CreatedAt;
type Title;
type ShortDescription;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Title = Unset;
type ShortDescription = Unset;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type CreatedAt = Set<members::created_at>;
type Title = St::Title;
type ShortDescription = St::ShortDescription;
}
pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTitle<St> {}
impl<St: State> State for SetTitle<St> {
type CreatedAt = St::CreatedAt;
type Title = Set<members::title>;
type ShortDescription = St::ShortDescription;
}
pub struct SetShortDescription<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetShortDescription<St> {}
impl<St: State> State for SetShortDescription<St> {
type CreatedAt = St::CreatedAt;
type Title = St::Title;
type ShortDescription = Set<members::short_description>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct title(());
pub struct short_description(());
}
}
pub struct ActivityBuilder<S: BosStr, St: activity_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<activity::Contributor<S>>>,
Option<Datetime>,
Option<LinearDocument<S>>,
Option<Datetime>,
Option<ActivityImage<S>>,
Option<Vec<StrongRef<S>>>,
Option<StrongRef<S>>,
Option<S>,
Option<Vec<Facet<S>>>,
Option<Datetime>,
Option<S>,
Option<ActivityWorkScope<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Activity<S> {
pub fn new() -> ActivityBuilder<S, activity_state::Empty> {
ActivityBuilder::new()
}
}
impl<S: BosStr> ActivityBuilder<S, activity_state::Empty> {
pub fn new() -> Self {
ActivityBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn contributors(mut self, value: impl Into<Option<Vec<activity::Contributor<S>>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_contributors(mut self, value: Option<Vec<activity::Contributor<S>>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> ActivityBuilder<S, St>
where
St: activity_state::State,
St::CreatedAt: activity_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ActivityBuilder<S, activity_state::SetCreatedAt<St>> {
self._fields.1 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<LinearDocument<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<LinearDocument<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
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<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn image(mut self, value: impl Into<Option<ActivityImage<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_image(mut self, value: Option<ActivityImage<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn locations(mut self, value: impl Into<Option<Vec<StrongRef<S>>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_locations(mut self, value: Option<Vec<StrongRef<S>>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn rights(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_rights(mut self, value: Option<StrongRef<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> ActivityBuilder<S, St>
where
St: activity_state::State,
St::ShortDescription: activity_state::IsUnset,
{
pub fn short_description(
mut self,
value: impl Into<S>,
) -> ActivityBuilder<S, activity_state::SetShortDescription<St>> {
self._fields.7 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn short_description_facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_short_description_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
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<S: BosStr, St> ActivityBuilder<S, St>
where
St: activity_state::State,
St::Title: activity_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<S>,
) -> ActivityBuilder<S, activity_state::SetTitle<St>> {
self._fields.10 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: activity_state::State> ActivityBuilder<S, St> {
pub fn work_scope(mut self, value: impl Into<Option<ActivityWorkScope<S>>>) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_work_scope(mut self, value: Option<ActivityWorkScope<S>>) -> Self {
self._fields.11 = value;
self
}
}
impl<S: BosStr, St> ActivityBuilder<S, St>
where
St: activity_state::State,
St::CreatedAt: activity_state::IsSet,
St::Title: activity_state::IsSet,
St::ShortDescription: activity_state::IsSet,
{
pub fn build(self) -> Activity<S> {
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<SmolStr, Data<S>>) -> Activity<S> {
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),
}
}
}