#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Rights<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub attachment: std::option::Option<RightsAttachment<'a>>,
pub created_at: jacquard_common::types::string::Datetime,
#[serde(borrow)]
pub rights_description: jacquard_common::CowStr<'a>,
#[serde(borrow)]
pub rights_name: jacquard_common::CowStr<'a>,
#[serde(borrow)]
pub rights_type: jacquard_common::CowStr<'a>,
}
pub mod rights_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 RightsName;
type RightsType;
type CreatedAt;
type RightsDescription;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type RightsName = Unset;
type RightsType = Unset;
type CreatedAt = Unset;
type RightsDescription = Unset;
}
pub struct SetRightsName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRightsName<S> {}
impl<S: State> State for SetRightsName<S> {
type RightsName = Set<members::rights_name>;
type RightsType = S::RightsType;
type CreatedAt = S::CreatedAt;
type RightsDescription = S::RightsDescription;
}
pub struct SetRightsType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRightsType<S> {}
impl<S: State> State for SetRightsType<S> {
type RightsName = S::RightsName;
type RightsType = Set<members::rights_type>;
type CreatedAt = S::CreatedAt;
type RightsDescription = S::RightsDescription;
}
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 RightsName = S::RightsName;
type RightsType = S::RightsType;
type CreatedAt = Set<members::created_at>;
type RightsDescription = S::RightsDescription;
}
pub struct SetRightsDescription<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRightsDescription<S> {}
impl<S: State> State for SetRightsDescription<S> {
type RightsName = S::RightsName;
type RightsType = S::RightsType;
type CreatedAt = S::CreatedAt;
type RightsDescription = Set<members::rights_description>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct rights_name(());
pub struct rights_type(());
pub struct created_at(());
pub struct rights_description(());
}
}
pub struct RightsBuilder<'a, S: rights_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<RightsAttachment<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Rights<'a> {
pub fn new() -> RightsBuilder<'a, rights_state::Empty> {
RightsBuilder::new()
}
}
impl<'a> RightsBuilder<'a, rights_state::Empty> {
pub fn new() -> Self {
RightsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: rights_state::State> RightsBuilder<'a, S> {
pub fn attachment(mut self, value: impl Into<Option<RightsAttachment<'a>>>) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_attachment(mut self, value: Option<RightsAttachment<'a>>) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> RightsBuilder<'a, S>
where
S: rights_state::State,
S::CreatedAt: rights_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> RightsBuilder<'a, rights_state::SetCreatedAt<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
RightsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RightsBuilder<'a, S>
where
S: rights_state::State,
S::RightsDescription: rights_state::IsUnset,
{
pub fn rights_description(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> RightsBuilder<'a, rights_state::SetRightsDescription<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
RightsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RightsBuilder<'a, S>
where
S: rights_state::State,
S::RightsName: rights_state::IsUnset,
{
pub fn rights_name(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> RightsBuilder<'a, rights_state::SetRightsName<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
RightsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RightsBuilder<'a, S>
where
S: rights_state::State,
S::RightsType: rights_state::IsUnset,
{
pub fn rights_type(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> RightsBuilder<'a, rights_state::SetRightsType<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
RightsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RightsBuilder<'a, S>
where
S: rights_state::State,
S::RightsName: rights_state::IsSet,
S::RightsType: rights_state::IsSet,
S::CreatedAt: rights_state::IsSet,
S::RightsDescription: rights_state::IsSet,
{
pub fn build(self) -> Rights<'a> {
Rights {
attachment: self.__unsafe_private_named.0,
created_at: self.__unsafe_private_named.1.unwrap(),
rights_description: self.__unsafe_private_named.2.unwrap(),
rights_name: self.__unsafe_private_named.3.unwrap(),
rights_type: self.__unsafe_private_named.4.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>,
>,
) -> Rights<'a> {
Rights {
attachment: self.__unsafe_private_named.0,
created_at: self.__unsafe_private_named.1.unwrap(),
rights_description: self.__unsafe_private_named.2.unwrap(),
rights_name: self.__unsafe_private_named.3.unwrap(),
rights_type: self.__unsafe_private_named.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> Rights<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, RightsRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[jacquard_derive::open_union]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum RightsAttachment<'a> {
#[serde(rename = "org.hypercerts.defs#uri")]
Uri(Box<crate::org_hypercerts::Uri<'a>>),
#[serde(rename = "org.hypercerts.defs#smallBlob")]
SmallBlob(Box<crate::org_hypercerts::SmallBlob<'a>>),
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct RightsGetRecordOutput<'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: Rights<'a>,
}
impl From<RightsGetRecordOutput<'_>> for Rights<'_> {
fn from(output: RightsGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Rights<'_> {
const NSID: &'static str = "org.hypercerts.claim.rights";
type Record = RightsRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct RightsRecord;
impl jacquard_common::xrpc::XrpcResp for RightsRecord {
const NSID: &'static str = "org.hypercerts.claim.rights";
const ENCODING: &'static str = "application/json";
type Output<'de> = RightsGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for RightsRecord {
const NSID: &'static str = "org.hypercerts.claim.rights";
type Record = RightsRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Rights<'a> {
fn nsid() -> &'static str {
"org.hypercerts.claim.rights"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_org_hypercerts_claim_rights()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.rights_description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"rights_description",
),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.rights_description;
{
let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes(
value.as_ref(),
true,
)
.count();
if count > 1000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"rights_description",
),
max: 1000usize,
actual: count,
});
}
}
}
{
let value = &self.rights_name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"rights_name",
),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.rights_type;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"rights_type",
),
max: 10usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_org_hypercerts_claim_rights() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("org.hypercerts.claim.rights"),
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(
"Describes the rights that a contributor and/or an owner has, such as whether the hypercert can be sold, transferred, and under what conditions.",
),
),
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("rightsName"),
::jacquard_common::deps::smol_str::SmolStr::new_static("rightsType"),
::jacquard_common::deps::smol_str::SmolStr::new_static("rightsDescription"),
::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(
"attachment",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
description: Some(
::jacquard_common::CowStr::new_static(
"An attachment to define the rights further, e.g. a legal document.",
),
),
refs: vec![
::jacquard_common::CowStr::new_static("org.hypercerts.defs#uri"),
::jacquard_common::CowStr::new_static("org.hypercerts.defs#smallBlob")
],
closed: None,
}),
);
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(
"Client-declared timestamp when this record was originally 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(
"rightsDescription",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Detailed explanation of the rights holders' permissions, restrictions, and conditions",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(10000usize),
min_graphemes: None,
max_graphemes: Some(1000usize),
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"rightsName",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Human-readable name for these rights (e.g. 'All Rights Reserved', 'CC BY-SA 4.0')",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(100usize),
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(
"rightsType",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Short identifier code for this rights type (e.g. 'ARR', 'CC-BY-SA') to facilitate filtering and search",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(10usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}