pub mod grant_verifications;
pub mod list_verifications;
pub mod revoke_verifications;
#[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::string::{Did, Handle, AtUri, Datetime};
use jacquard_common::types::value::Data;
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::tools_ozone::moderation::RepoViewDetail;
use crate::tools_ozone::moderation::RepoViewNotFound;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct VerificationView<'a> {
pub created_at: Datetime,
#[serde(borrow)]
pub display_name: CowStr<'a>,
#[serde(borrow)]
pub handle: Handle<'a>,
#[serde(borrow)]
pub issuer: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub issuer_profile: Option<Data<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub issuer_repo: Option<VerificationViewIssuerRepo<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub revoke_reason: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub revoked_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub revoked_by: Option<Did<'a>>,
#[serde(borrow)]
pub subject: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub subject_profile: Option<Data<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub subject_repo: Option<VerificationViewSubjectRepo<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum VerificationViewIssuerRepo<'a> {
#[serde(rename = "tools.ozone.moderation.defs#repoViewDetail")]
RepoViewDetail(Box<RepoViewDetail<'a>>),
#[serde(rename = "tools.ozone.moderation.defs#repoViewNotFound")]
RepoViewNotFound(Box<RepoViewNotFound<'a>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum VerificationViewSubjectRepo<'a> {
#[serde(rename = "tools.ozone.moderation.defs#repoViewDetail")]
RepoViewDetail(Box<RepoViewDetail<'a>>),
#[serde(rename = "tools.ozone.moderation.defs#repoViewNotFound")]
RepoViewNotFound(Box<RepoViewNotFound<'a>>),
}
impl<'a> LexiconSchema for VerificationView<'a> {
fn nsid() -> &'static str {
"tools.ozone.verification.defs"
}
fn def_name() -> &'static str {
"verificationView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_verification_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod verification_view_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 DisplayName;
type Issuer;
type CreatedAt;
type Subject;
type Handle;
type Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type DisplayName = Unset;
type Issuer = Unset;
type CreatedAt = Unset;
type Subject = Unset;
type Handle = Unset;
type Uri = Unset;
}
pub struct SetDisplayName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDisplayName<S> {}
impl<S: State> State for SetDisplayName<S> {
type DisplayName = Set<members::display_name>;
type Issuer = S::Issuer;
type CreatedAt = S::CreatedAt;
type Subject = S::Subject;
type Handle = S::Handle;
type Uri = S::Uri;
}
pub struct SetIssuer<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIssuer<S> {}
impl<S: State> State for SetIssuer<S> {
type DisplayName = S::DisplayName;
type Issuer = Set<members::issuer>;
type CreatedAt = S::CreatedAt;
type Subject = S::Subject;
type Handle = S::Handle;
type Uri = S::Uri;
}
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 DisplayName = S::DisplayName;
type Issuer = S::Issuer;
type CreatedAt = Set<members::created_at>;
type Subject = S::Subject;
type Handle = S::Handle;
type Uri = S::Uri;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type DisplayName = S::DisplayName;
type Issuer = S::Issuer;
type CreatedAt = S::CreatedAt;
type Subject = Set<members::subject>;
type Handle = S::Handle;
type Uri = S::Uri;
}
pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHandle<S> {}
impl<S: State> State for SetHandle<S> {
type DisplayName = S::DisplayName;
type Issuer = S::Issuer;
type CreatedAt = S::CreatedAt;
type Subject = S::Subject;
type Handle = Set<members::handle>;
type Uri = S::Uri;
}
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 DisplayName = S::DisplayName;
type Issuer = S::Issuer;
type CreatedAt = S::CreatedAt;
type Subject = S::Subject;
type Handle = S::Handle;
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct display_name(());
pub struct issuer(());
pub struct created_at(());
pub struct subject(());
pub struct handle(());
pub struct uri(());
}
}
pub struct VerificationViewBuilder<'a, S: verification_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<Handle<'a>>,
Option<Did<'a>>,
Option<Data<'a>>,
Option<VerificationViewIssuerRepo<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<Did<'a>>,
Option<Did<'a>>,
Option<Data<'a>>,
Option<VerificationViewSubjectRepo<'a>>,
Option<AtUri<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> VerificationView<'a> {
pub fn new() -> VerificationViewBuilder<'a, verification_view_state::Empty> {
VerificationViewBuilder::new()
}
}
impl<'a> VerificationViewBuilder<'a, verification_view_state::Empty> {
pub fn new() -> Self {
VerificationViewBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::CreatedAt: verification_view_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> VerificationViewBuilder<'a, verification_view_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::DisplayName: verification_view_state::IsUnset,
{
pub fn display_name(
mut self,
value: impl Into<CowStr<'a>>,
) -> VerificationViewBuilder<'a, verification_view_state::SetDisplayName<S>> {
self._fields.1 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::Handle: verification_view_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<Handle<'a>>,
) -> VerificationViewBuilder<'a, verification_view_state::SetHandle<S>> {
self._fields.2 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::Issuer: verification_view_state::IsUnset,
{
pub fn issuer(
mut self,
value: impl Into<Did<'a>>,
) -> VerificationViewBuilder<'a, verification_view_state::SetIssuer<S>> {
self._fields.3 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn issuer_profile(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_issuer_profile(mut self, value: Option<Data<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn issuer_repo(
mut self,
value: impl Into<Option<VerificationViewIssuerRepo<'a>>>,
) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_issuer_repo(
mut self,
value: Option<VerificationViewIssuerRepo<'a>>,
) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn revoke_reason(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_revoke_reason(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn revoked_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_revoked_at(mut self, value: Option<Datetime>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn revoked_by(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_revoked_by(mut self, value: Option<Did<'a>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::Subject: verification_view_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<Did<'a>>,
) -> VerificationViewBuilder<'a, verification_view_state::SetSubject<S>> {
self._fields.9 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn subject_profile(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_subject_profile(mut self, value: Option<Data<'a>>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S: verification_view_state::State> VerificationViewBuilder<'a, S> {
pub fn subject_repo(
mut self,
value: impl Into<Option<VerificationViewSubjectRepo<'a>>>,
) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_subject_repo(
mut self,
value: Option<VerificationViewSubjectRepo<'a>>,
) -> Self {
self._fields.11 = value;
self
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::Uri: verification_view_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> VerificationViewBuilder<'a, verification_view_state::SetUri<S>> {
self._fields.12 = Option::Some(value.into());
VerificationViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> VerificationViewBuilder<'a, S>
where
S: verification_view_state::State,
S::DisplayName: verification_view_state::IsSet,
S::Issuer: verification_view_state::IsSet,
S::CreatedAt: verification_view_state::IsSet,
S::Subject: verification_view_state::IsSet,
S::Handle: verification_view_state::IsSet,
S::Uri: verification_view_state::IsSet,
{
pub fn build(self) -> VerificationView<'a> {
VerificationView {
created_at: self._fields.0.unwrap(),
display_name: self._fields.1.unwrap(),
handle: self._fields.2.unwrap(),
issuer: self._fields.3.unwrap(),
issuer_profile: self._fields.4,
issuer_repo: self._fields.5,
revoke_reason: self._fields.6,
revoked_at: self._fields.7,
revoked_by: self._fields.8,
subject: self._fields.9.unwrap(),
subject_profile: self._fields.10,
subject_repo: self._fields.11,
uri: self._fields.12.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> VerificationView<'a> {
VerificationView {
created_at: self._fields.0.unwrap(),
display_name: self._fields.1.unwrap(),
handle: self._fields.2.unwrap(),
issuer: self._fields.3.unwrap(),
issuer_profile: self._fields.4,
issuer_repo: self._fields.5,
revoke_reason: self._fields.6,
revoked_at: self._fields.7,
revoked_by: self._fields.8,
subject: self._fields.9.unwrap(),
subject_profile: self._fields.10,
subject_repo: self._fields.11,
uri: self._fields.12.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_tools_ozone_verification_defs() -> 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("tools.ozone.verification.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("verificationView"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Verification data for the associated subject.",
),
),
required: Some(
vec![
SmolStr::new_static("issuer"), SmolStr::new_static("uri"),
SmolStr::new_static("subject"),
SmolStr::new_static("handle"),
SmolStr::new_static("displayName"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp when the verification was created.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Display name of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current displayName matches the one at the time of verifying.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Handle of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current handle matches the one at the time of verifying.",
),
),
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issuer"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The user who issued this verification."),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issuerProfile"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issuerRepo"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("tools.ozone.moderation.defs#repoViewDetail"),
CowStr::new_static("tools.ozone.moderation.defs#repoViewNotFound")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("revokeReason"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Describes the reason for revocation, also indicating that the verification is no longer valid.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("revokedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp when the verification was revoked.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("revokedBy"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The user who revoked this verification.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The subject of the verification."),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjectProfile"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjectRepo"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("tools.ozone.moderation.defs#repoViewDetail"),
CowStr::new_static("tools.ozone.moderation.defs#repoViewNotFound")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The AT-URI of the verification record."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}