//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `persona/disclosure/preview`. Version: `1.0`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
/**
The vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.
The token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.
The `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ClaimType",
/// "description": "\nThe vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.\n\nThe token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.\n\nThe `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1,
/// "pattern": "^(x:)?[a-z][a-zA-Z0-9]*(\\.[a-z][a-zA-Z0-9]*)*$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ClaimType(::std::string::String);
impl ::std::ops::Deref for ClaimType {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ClaimType> for ::std::string::String {
fn from(value: ClaimType) -> Self {
value.0
}
}
impl ::std::str::FromStr for ClaimType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^(x:)?[a-z][a-zA-Z0-9]*(\\.[a-z][a-zA-Z0-9]*)*$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^(x:)?[a-z][a-zA-Z0-9]*(\\.[a-z][a-zA-Z0-9]*)*$\"".into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ClaimType {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ClaimType {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ClaimType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ClaimType {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Determine exactly what a disclosure would reveal, and to whom, without signing or sending anything. The first of two calls that cannot be collapsed: there is no path to a disclosure that did not first produce the summary a human can be shown.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/persona/disclosure/preview/1.0",
/// "title": "Payload",
/// "description": "Determine exactly what a disclosure would reveal, and to whom, without signing or sending anything. The first of two calls that cannot be collapsed: there is no path to a disclosure that did not first produce the summary a human can be shown.",
/// "type": "object",
/// "required": [
/// "contextId",
/// "personaDid",
/// "verifierDid"
/// ],
/// "properties": {
/// "contextId": {
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "personaDid": {
/// "description": "The persona that would present. Its binding supplies the profile.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "purpose": {
/// "description": "The verifier's stated reason, carried through to the preview and the disclosure record so a holder deciding later has the same context as one deciding now.",
/// "type": "string",
/// "maxLength": 512
/// },
/// "renderer": {
/// "description": "Which output format to prepare for. Omit for the maintainer's canonical form. The choice matters to the preview because renderers differ in what they can carry, and a holder is owed that before deciding.",
/// "type": "string",
/// "maxLength": 64
/// },
/// "requestedClaims": {
/// "description": "Claim types the verifier asked for. Omit to preview everything the bound profile would present. A maintainer MUST NOT return a claim that was not requested when this member is present — narrowing is the caller's to ask for and the maintainer's to honour.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "maxItems": 128
/// },
/// "verifierDid": {
/// "description": "Who would receive it. Required, and not optional, because half of what a preview says is who is asking — a preview that could not name the recipient would be a list of fields rather than a decision.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The persona that would present. Its binding supplies the profile.
#[serde(rename = "personaDid")]
pub persona_did: PayloadPersonaDid,
///The verifier's stated reason, carried through to the preview and the disclosure record so a holder deciding later has the same context as one deciding now.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<PayloadPurpose>,
///Which output format to prepare for. Omit for the maintainer's canonical form. The choice matters to the preview because renderers differ in what they can carry, and a holder is owed that before deciding.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub renderer: ::std::option::Option<PayloadRenderer>,
///Claim types the verifier asked for. Omit to preview everything the bound profile would present. A maintainer MUST NOT return a claim that was not requested when this member is present — narrowing is the caller's to ask for and the maintainer's to honour.
#[serde(
rename = "requestedClaims",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub requested_claims: ::std::vec::Vec<ClaimType>,
///Who would receive it. Required, and not optional, because half of what a preview says is who is asking — a preview that could not name the recipient would be a list of fields rather than a decision.
#[serde(rename = "verifierDid")]
pub verifier_did: PayloadVerifierDid,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///`PayloadContextId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadContextId(::std::string::String);
impl ::std::ops::Deref for PayloadContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadContextId> for ::std::string::String {
fn from(value: PayloadContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadContextId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadContextId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadContextId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadContextId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadContextId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The persona that would present. Its binding supplies the profile.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The persona that would present. Its binding supplies the profile.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadPersonaDid(::std::string::String);
impl ::std::ops::Deref for PayloadPersonaDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadPersonaDid> for ::std::string::String {
fn from(value: PayloadPersonaDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadPersonaDid {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadPersonaDid {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadPersonaDid {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadPersonaDid {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadPersonaDid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The verifier's stated reason, carried through to the preview and the disclosure record so a holder deciding later has the same context as one deciding now.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The verifier's stated reason, carried through to the preview and the disclosure record so a holder deciding later has the same context as one deciding now.",
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadPurpose(::std::string::String);
impl ::std::ops::Deref for PayloadPurpose {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadPurpose> for ::std::string::String {
fn from(value: PayloadPurpose) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadPurpose {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadPurpose {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadPurpose {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Which output format to prepare for. Omit for the maintainer's canonical form. The choice matters to the preview because renderers differ in what they can carry, and a holder is owed that before deciding.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Which output format to prepare for. Omit for the maintainer's canonical form. The choice matters to the preview because renderers differ in what they can carry, and a holder is owed that before deciding.",
/// "type": "string",
/// "maxLength": 64
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadRenderer(::std::string::String);
impl ::std::ops::Deref for PayloadRenderer {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadRenderer> for ::std::string::String {
fn from(value: PayloadRenderer) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadRenderer {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadRenderer {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadRenderer {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadRenderer {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadRenderer {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Who would receive it. Required, and not optional, because half of what a preview says is who is asking — a preview that could not name the recipient would be a list of fields rather than a decision.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Who would receive it. Required, and not optional, because half of what a preview says is who is asking — a preview that could not name the recipient would be a list of fields rather than a decision.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadVerifierDid(::std::string::String);
impl ::std::ops::Deref for PayloadVerifierDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadVerifierDid> for ::std::string::String {
fn from(value: PayloadVerifierDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadVerifierDid {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadVerifierDid {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadVerifierDid {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadVerifierDid {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadVerifierDid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/**
How strongly a credential-backed claim is hidden when presented, ordered most private first. `predicate` proves a statement over a claim without disclosing the claim. `derived` discloses exactly the claims needed via an unlinkable derived proof, so two presentations cannot be joined. `selectiveDisclosure` discloses exactly the claims needed but carries the issuer's signature unchanged, so two presentations ARE linkable. `whole` discloses the entire credential.
The distinction between the first two and the last two is of kind, not degree: only `predicate` and `derived` avoid handing two verifiers a join key. A maintainer MUST default to the highest rung the credential's format supports, and MUST NOT silently fall to a lower one — a request that cannot be satisfied at the rung a producer asked for is refused, because a silent privacy downgrade discloses material the holder believed was hidden.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ProofRung",
/// "description": "\nHow strongly a credential-backed claim is hidden when presented, ordered most private first. `predicate` proves a statement over a claim without disclosing the claim. `derived` discloses exactly the claims needed via an unlinkable derived proof, so two presentations cannot be joined. `selectiveDisclosure` discloses exactly the claims needed but carries the issuer's signature unchanged, so two presentations ARE linkable. `whole` discloses the entire credential.\n\nThe distinction between the first two and the last two is of kind, not degree: only `predicate` and `derived` avoid handing two verifiers a join key. A maintainer MUST default to the highest rung the credential's format supports, and MUST NOT silently fall to a lower one — a request that cannot be satisfied at the rung a producer asked for is refused, because a silent privacy downgrade discloses material the holder believed was hidden.",
/// "type": "string",
/// "enum": [
/// "predicate",
/// "derived",
/// "selectiveDisclosure",
/// "whole"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ProofRung {
#[serde(rename = "predicate")]
Predicate,
#[serde(rename = "derived")]
Derived,
#[serde(rename = "selectiveDisclosure")]
SelectiveDisclosure,
#[serde(rename = "whole")]
Whole,
}
impl ::std::fmt::Display for ProofRung {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Predicate => f.write_str("predicate"),
Self::Derived => f.write_str("derived"),
Self::SelectiveDisclosure => f.write_str("selectiveDisclosure"),
Self::Whole => f.write_str("whole"),
}
}
}
impl ::std::str::FromStr for ProofRung {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"predicate" => Ok(Self::Predicate),
"derived" => Ok(Self::Derived),
"selectiveDisclosure" => Ok(Self::SelectiveDisclosure),
"whole" => Ok(Self::Whole),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ProofRung {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ProofRung {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ProofRung {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Success response to persona/disclosure/preview. Type https://trusttasks.org/spec/persona/disclosure/preview/1.0#response. Signs nothing and sends nothing. The `previewId` returned here is consumed by persona/disclosure/present, which is the mechanism by which the two calls cannot be collapsed.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to persona/disclosure/preview. Type https://trusttasks.org/spec/persona/disclosure/preview/1.0#response. Signs nothing and sends nothing. The `previewId` returned here is consumed by persona/disclosure/present, which is the mechanism by which the two calls cannot be collapsed.",
/// "type": "object",
/// "required": [
/// "claims",
/// "expiresAt",
/// "previewId",
/// "subject"
/// ],
/// "properties": {
/// "anomalous": {
/// "description": "Claim types unusual for this verifier's stated purpose. A preview that lists fourteen fields with fourteen equal weights is a notice-and-consent dialog, which is the pattern that trains people to click through; ranking by what is out of place is what makes the surfaced line the one worth reading.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "maxItems": 128
/// },
/// "claims": {
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "provenance",
/// "rung",
/// "type"
/// ],
/// "properties": {
/// "newToThisVerifier": {
/// "description": "True when this verifier has not previously received this claim type from this persona. What makes a preview rankable rather than a flat list — a holder needs the unusual ask to stand out from the routine one.",
/// "type": "boolean"
/// },
/// "predicate": {
/// "description": "Present instead of `value` when the claim would be proven rather than shown, e.g. that a date of birth implies an age threshold. The underlying attribute stays in the pool; the predicate is a disclosure-time projection over it, which is what keeps the pool from filling with derived facts that are all the same fact asked differently.",
/// "type": "object",
/// "required": [
/// "arg",
/// "op"
/// ],
/// "properties": {
/// "arg": {},
/// "op": {
/// "type": "string",
/// "enum": [
/// "gte",
/// "gt",
/// "lte",
/// "lt",
/// "eq",
/// "ne",
/// "memberOf"
/// ]
/// },
/// "over": {
/// "$ref": "#/definitions/ClaimType"
/// }
/// },
/// "additionalProperties": false
/// },
/// "provenance": {
/// "type": "string",
/// "enum": [
/// "selfAsserted",
/// "credentialBacked",
/// "generated",
/// "derived"
/// ]
/// },
/// "rung": {
/// "$ref": "#/definitions/ProofRung"
/// },
/// "stale": {
/// "description": "True when a credential-backed claim could not be re-derived. Such a claim MUST NOT be disclosed; it is shown in the preview so the holder learns why the disclosure will be short.",
/// "type": "boolean"
/// },
/// "type": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "value": {
/// "description": "What would be disclosed. Absent for a predicate claim, which discloses no value at all — that absence is the point and a consumer MUST NOT render it as missing data."
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 128
/// },
/// "correlation": {
/// "description": "How much this disclosure would link the holder. Note the inversion that is easy to get backwards: a credential presented WHOLE correlates more than a self-asserted value, because the issuer signature is identical at every verifier — while a derived proof correlates LESS, because it differs on every presentation. Severity is therefore a function of value and rung together, not of provenance alone.",
/// "type": "object",
/// "required": [
/// "severity"
/// ],
/// "properties": {
/// "reason": {
/// "type": "string",
/// "maxLength": 512
/// },
/// "severity": {
/// "type": "string",
/// "enum": [
/// "none",
/// "low",
/// "high"
/// ]
/// }
/// },
/// "additionalProperties": false
/// },
/// "expiresAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "previewId": {
/// "description": "Consumed by present. Single-use and short-lived: a preview a holder approved an hour ago is not evidence they approve it now, and one that could be replayed would let a second disclosure ride an earlier decision.",
/// "$ref": "#/definitions/Ulid"
/// },
/// "renderer": {
/// "description": "The output format and, crucially, what it cannot carry. Lossiness is DECLARED rather than discovered: a holder is owed 'this verifier will see your work number but not that your employer attested it' before deciding, not after.",
/// "type": "object",
/// "required": [
/// "drops",
/// "id"
/// ],
/// "properties": {
/// "drops": {
/// "description": "What this renderer discards — commonly provenance. Empty for a lossless renderer.",
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 64
/// },
/// "maxItems": 32
/// },
/// "id": {
/// "type": "string",
/// "maxLength": 64
/// }
/// },
/// "additionalProperties": false
/// },
/// "subject": {
/// "description": "The identifier that would appear as the subject of the disclosure. Pairwise by default — a fresh per-relationship DID rather than the persona DID — so that two verifiers cannot recognise the holder as the same party. The persona DID is the account; this is the face.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///Claim types unusual for this verifier's stated purpose. A preview that lists fourteen fields with fourteen equal weights is a notice-and-consent dialog, which is the pattern that trains people to click through; ranking by what is out of place is what makes the surfaced line the one worth reading.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub anomalous: ::std::vec::Vec<ClaimType>,
pub claims: ::std::vec::Vec<ResponseClaimsItem>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub correlation: ::std::option::Option<ResponseCorrelation>,
#[serde(rename = "expiresAt")]
pub expires_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Consumed by present. Single-use and short-lived: a preview a holder approved an hour ago is not evidence they approve it now, and one that could be replayed would let a second disclosure ride an earlier decision.
#[serde(rename = "previewId")]
pub preview_id: Ulid,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub renderer: ::std::option::Option<ResponseRenderer>,
///The identifier that would appear as the subject of the disclosure. Pairwise by default — a fresh per-relationship DID rather than the persona DID — so that two verifiers cannot recognise the holder as the same party. The persona DID is the account; this is the face.
pub subject: ResponseSubject,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseClaimsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "provenance",
/// "rung",
/// "type"
/// ],
/// "properties": {
/// "newToThisVerifier": {
/// "description": "True when this verifier has not previously received this claim type from this persona. What makes a preview rankable rather than a flat list — a holder needs the unusual ask to stand out from the routine one.",
/// "type": "boolean"
/// },
/// "predicate": {
/// "description": "Present instead of `value` when the claim would be proven rather than shown, e.g. that a date of birth implies an age threshold. The underlying attribute stays in the pool; the predicate is a disclosure-time projection over it, which is what keeps the pool from filling with derived facts that are all the same fact asked differently.",
/// "type": "object",
/// "required": [
/// "arg",
/// "op"
/// ],
/// "properties": {
/// "arg": {},
/// "op": {
/// "type": "string",
/// "enum": [
/// "gte",
/// "gt",
/// "lte",
/// "lt",
/// "eq",
/// "ne",
/// "memberOf"
/// ]
/// },
/// "over": {
/// "$ref": "#/definitions/ClaimType"
/// }
/// },
/// "additionalProperties": false
/// },
/// "provenance": {
/// "type": "string",
/// "enum": [
/// "selfAsserted",
/// "credentialBacked",
/// "generated",
/// "derived"
/// ]
/// },
/// "rung": {
/// "$ref": "#/definitions/ProofRung"
/// },
/// "stale": {
/// "description": "True when a credential-backed claim could not be re-derived. Such a claim MUST NOT be disclosed; it is shown in the preview so the holder learns why the disclosure will be short.",
/// "type": "boolean"
/// },
/// "type": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "value": {
/// "description": "What would be disclosed. Absent for a predicate claim, which discloses no value at all — that absence is the point and a consumer MUST NOT render it as missing data."
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseClaimsItem {
///True when this verifier has not previously received this claim type from this persona. What makes a preview rankable rather than a flat list — a holder needs the unusual ask to stand out from the routine one.
#[serde(
rename = "newToThisVerifier",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub new_to_this_verifier: ::std::option::Option<bool>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub predicate: ::std::option::Option<ResponseClaimsItemPredicate>,
pub provenance: ResponseClaimsItemProvenance,
pub rung: ProofRung,
///True when a credential-backed claim could not be re-derived. Such a claim MUST NOT be disclosed; it is shown in the preview so the holder learns why the disclosure will be short.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub stale: ::std::option::Option<bool>,
#[serde(rename = "type")]
pub type_: ClaimType,
///What would be disclosed. Absent for a predicate claim, which discloses no value at all — that absence is the point and a consumer MUST NOT render it as missing data.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub value: ::std::option::Option<::serde_json::Value>,
}
impl ResponseClaimsItem {
pub fn builder() -> builder::ResponseClaimsItem {
Default::default()
}
}
///Present instead of `value` when the claim would be proven rather than shown, e.g. that a date of birth implies an age threshold. The underlying attribute stays in the pool; the predicate is a disclosure-time projection over it, which is what keeps the pool from filling with derived facts that are all the same fact asked differently.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Present instead of `value` when the claim would be proven rather than shown, e.g. that a date of birth implies an age threshold. The underlying attribute stays in the pool; the predicate is a disclosure-time projection over it, which is what keeps the pool from filling with derived facts that are all the same fact asked differently.",
/// "type": "object",
/// "required": [
/// "arg",
/// "op"
/// ],
/// "properties": {
/// "arg": {},
/// "op": {
/// "type": "string",
/// "enum": [
/// "gte",
/// "gt",
/// "lte",
/// "lt",
/// "eq",
/// "ne",
/// "memberOf"
/// ]
/// },
/// "over": {
/// "$ref": "#/definitions/ClaimType"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseClaimsItemPredicate {
pub arg: ::serde_json::Value,
pub op: ResponseClaimsItemPredicateOp,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub over: ::std::option::Option<ClaimType>,
}
impl ResponseClaimsItemPredicate {
pub fn builder() -> builder::ResponseClaimsItemPredicate {
Default::default()
}
}
///`ResponseClaimsItemPredicateOp`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "gte",
/// "gt",
/// "lte",
/// "lt",
/// "eq",
/// "ne",
/// "memberOf"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseClaimsItemPredicateOp {
#[serde(rename = "gte")]
Gte,
#[serde(rename = "gt")]
Gt,
#[serde(rename = "lte")]
Lte,
#[serde(rename = "lt")]
Lt,
#[serde(rename = "eq")]
Eq,
#[serde(rename = "ne")]
Ne,
#[serde(rename = "memberOf")]
MemberOf,
}
impl ::std::fmt::Display for ResponseClaimsItemPredicateOp {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Gte => f.write_str("gte"),
Self::Gt => f.write_str("gt"),
Self::Lte => f.write_str("lte"),
Self::Lt => f.write_str("lt"),
Self::Eq => f.write_str("eq"),
Self::Ne => f.write_str("ne"),
Self::MemberOf => f.write_str("memberOf"),
}
}
}
impl ::std::str::FromStr for ResponseClaimsItemPredicateOp {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"gte" => Ok(Self::Gte),
"gt" => Ok(Self::Gt),
"lte" => Ok(Self::Lte),
"lt" => Ok(Self::Lt),
"eq" => Ok(Self::Eq),
"ne" => Ok(Self::Ne),
"memberOf" => Ok(Self::MemberOf),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseClaimsItemPredicateOp {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseClaimsItemPredicateOp {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseClaimsItemPredicateOp {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`ResponseClaimsItemProvenance`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "selfAsserted",
/// "credentialBacked",
/// "generated",
/// "derived"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseClaimsItemProvenance {
#[serde(rename = "selfAsserted")]
SelfAsserted,
#[serde(rename = "credentialBacked")]
CredentialBacked,
#[serde(rename = "generated")]
Generated,
#[serde(rename = "derived")]
Derived,
}
impl ::std::fmt::Display for ResponseClaimsItemProvenance {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::SelfAsserted => f.write_str("selfAsserted"),
Self::CredentialBacked => f.write_str("credentialBacked"),
Self::Generated => f.write_str("generated"),
Self::Derived => f.write_str("derived"),
}
}
}
impl ::std::str::FromStr for ResponseClaimsItemProvenance {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"selfAsserted" => Ok(Self::SelfAsserted),
"credentialBacked" => Ok(Self::CredentialBacked),
"generated" => Ok(Self::Generated),
"derived" => Ok(Self::Derived),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseClaimsItemProvenance {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseClaimsItemProvenance {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseClaimsItemProvenance {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///How much this disclosure would link the holder. Note the inversion that is easy to get backwards: a credential presented WHOLE correlates more than a self-asserted value, because the issuer signature is identical at every verifier — while a derived proof correlates LESS, because it differs on every presentation. Severity is therefore a function of value and rung together, not of provenance alone.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "How much this disclosure would link the holder. Note the inversion that is easy to get backwards: a credential presented WHOLE correlates more than a self-asserted value, because the issuer signature is identical at every verifier — while a derived proof correlates LESS, because it differs on every presentation. Severity is therefore a function of value and rung together, not of provenance alone.",
/// "type": "object",
/// "required": [
/// "severity"
/// ],
/// "properties": {
/// "reason": {
/// "type": "string",
/// "maxLength": 512
/// },
/// "severity": {
/// "type": "string",
/// "enum": [
/// "none",
/// "low",
/// "high"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseCorrelation {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub reason: ::std::option::Option<ResponseCorrelationReason>,
pub severity: ResponseCorrelationSeverity,
}
impl ResponseCorrelation {
pub fn builder() -> builder::ResponseCorrelation {
Default::default()
}
}
///`ResponseCorrelationReason`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseCorrelationReason(::std::string::String);
impl ::std::ops::Deref for ResponseCorrelationReason {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseCorrelationReason> for ::std::string::String {
fn from(value: ResponseCorrelationReason) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseCorrelationReason {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseCorrelationReason {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseCorrelationReason {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseCorrelationReason {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseCorrelationReason {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ResponseCorrelationSeverity`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "none",
/// "low",
/// "high"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseCorrelationSeverity {
#[serde(rename = "none")]
None,
#[serde(rename = "low")]
Low,
#[serde(rename = "high")]
High,
}
impl ::std::fmt::Display for ResponseCorrelationSeverity {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::None => f.write_str("none"),
Self::Low => f.write_str("low"),
Self::High => f.write_str("high"),
}
}
}
impl ::std::str::FromStr for ResponseCorrelationSeverity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"none" => Ok(Self::None),
"low" => Ok(Self::Low),
"high" => Ok(Self::High),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseCorrelationSeverity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseCorrelationSeverity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseCorrelationSeverity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The output format and, crucially, what it cannot carry. Lossiness is DECLARED rather than discovered: a holder is owed 'this verifier will see your work number but not that your employer attested it' before deciding, not after.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The output format and, crucially, what it cannot carry. Lossiness is DECLARED rather than discovered: a holder is owed 'this verifier will see your work number but not that your employer attested it' before deciding, not after.",
/// "type": "object",
/// "required": [
/// "drops",
/// "id"
/// ],
/// "properties": {
/// "drops": {
/// "description": "What this renderer discards — commonly provenance. Empty for a lossless renderer.",
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 64
/// },
/// "maxItems": 32
/// },
/// "id": {
/// "type": "string",
/// "maxLength": 64
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseRenderer {
///What this renderer discards — commonly provenance. Empty for a lossless renderer.
pub drops: ::std::vec::Vec<ResponseRendererDropsItem>,
pub id: ResponseRendererId,
}
impl ResponseRenderer {
pub fn builder() -> builder::ResponseRenderer {
Default::default()
}
}
///`ResponseRendererDropsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 64
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseRendererDropsItem(::std::string::String);
impl ::std::ops::Deref for ResponseRendererDropsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseRendererDropsItem> for ::std::string::String {
fn from(value: ResponseRendererDropsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseRendererDropsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseRendererDropsItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseRendererDropsItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseRendererDropsItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseRendererDropsItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ResponseRendererId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 64
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseRendererId(::std::string::String);
impl ::std::ops::Deref for ResponseRendererId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseRendererId> for ::std::string::String {
fn from(value: ResponseRendererId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseRendererId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseRendererId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseRendererId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseRendererId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseRendererId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The identifier that would appear as the subject of the disclosure. Pairwise by default — a fresh per-relationship DID rather than the persona DID — so that two verifiers cannot recognise the holder as the same party. The persona DID is the account; this is the face.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The identifier that would appear as the subject of the disclosure. Pairwise by default — a fresh per-relationship DID rather than the persona DID — so that two verifiers cannot recognise the holder as the same party. The persona DID is the account; this is the face.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseSubject(::std::string::String);
impl ::std::ops::Deref for ResponseSubject {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseSubject> for ::std::string::String {
fn from(value: ResponseSubject) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseSubject {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseSubject {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseSubject {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseSubject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseSubject {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ulid",
/// "description": "A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.",
/// "type": "string",
/// "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Ulid(::std::string::String);
impl ::std::ops::Deref for Ulid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Ulid> for ::std::string::String {
fn from(value: Ulid) -> Self {
value.0
}
}
impl ::std::str::FromStr for Ulid {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[0-9A-HJKMNP-TV-Z]{26}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[0-9A-HJKMNP-TV-Z]{26}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Ulid {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Ulid {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Ulid {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for Ulid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
persona_did: ::std::result::Result<super::PayloadPersonaDid, ::std::string::String>,
purpose: ::std::result::Result<
::std::option::Option<super::PayloadPurpose>,
::std::string::String,
>,
renderer: ::std::result::Result<
::std::option::Option<super::PayloadRenderer>,
::std::string::String,
>,
requested_claims:
::std::result::Result<::std::vec::Vec<super::ClaimType>, ::std::string::String>,
verifier_did: ::std::result::Result<super::PayloadVerifierDid, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
context_id: Err("no value supplied for context_id".to_string()),
ext: Ok(Default::default()),
persona_did: Err("no value supplied for persona_did".to_string()),
purpose: Ok(Default::default()),
renderer: Ok(Default::default()),
requested_claims: Ok(Default::default()),
verifier_did: Err("no value supplied for verifier_did".to_string()),
}
}
}
impl Payload {
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadContextId>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn persona_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadPersonaDid>,
T::Error: ::std::fmt::Display,
{
self.persona_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for persona_did: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| format!("error converting supplied value for purpose: {e}"));
self
}
pub fn renderer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadRenderer>>,
T::Error: ::std::fmt::Display,
{
self.renderer = value
.try_into()
.map_err(|e| format!("error converting supplied value for renderer: {e}"));
self
}
pub fn requested_claims<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ClaimType>>,
T::Error: ::std::fmt::Display,
{
self.requested_claims = value
.try_into()
.map_err(|e| format!("error converting supplied value for requested_claims: {e}"));
self
}
pub fn verifier_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadVerifierDid>,
T::Error: ::std::fmt::Display,
{
self.verifier_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for verifier_did: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
context_id: value.context_id?,
ext: value.ext?,
persona_did: value.persona_did?,
purpose: value.purpose?,
renderer: value.renderer?,
requested_claims: value.requested_claims?,
verifier_did: value.verifier_did?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
context_id: Ok(value.context_id),
ext: Ok(value.ext),
persona_did: Ok(value.persona_did),
purpose: Ok(value.purpose),
renderer: Ok(value.renderer),
requested_claims: Ok(value.requested_claims),
verifier_did: Ok(value.verifier_did),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
anomalous: ::std::result::Result<::std::vec::Vec<super::ClaimType>, ::std::string::String>,
claims: ::std::result::Result<
::std::vec::Vec<super::ResponseClaimsItem>,
::std::string::String,
>,
correlation: ::std::result::Result<
::std::option::Option<super::ResponseCorrelation>,
::std::string::String,
>,
expires_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
preview_id: ::std::result::Result<super::Ulid, ::std::string::String>,
renderer: ::std::result::Result<
::std::option::Option<super::ResponseRenderer>,
::std::string::String,
>,
subject: ::std::result::Result<super::ResponseSubject, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
anomalous: Ok(Default::default()),
claims: Err("no value supplied for claims".to_string()),
correlation: Ok(Default::default()),
expires_at: Err("no value supplied for expires_at".to_string()),
ext: Ok(Default::default()),
preview_id: Err("no value supplied for preview_id".to_string()),
renderer: Ok(Default::default()),
subject: Err("no value supplied for subject".to_string()),
}
}
}
impl Response {
pub fn anomalous<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ClaimType>>,
T::Error: ::std::fmt::Display,
{
self.anomalous = value
.try_into()
.map_err(|e| format!("error converting supplied value for anomalous: {e}"));
self
}
pub fn claims<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseClaimsItem>>,
T::Error: ::std::fmt::Display,
{
self.claims = value
.try_into()
.map_err(|e| format!("error converting supplied value for claims: {e}"));
self
}
pub fn correlation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCorrelation>>,
T::Error: ::std::fmt::Display,
{
self.correlation = value
.try_into()
.map_err(|e| format!("error converting supplied value for correlation: {e}"));
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn preview_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ulid>,
T::Error: ::std::fmt::Display,
{
self.preview_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for preview_id: {e}"));
self
}
pub fn renderer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseRenderer>>,
T::Error: ::std::fmt::Display,
{
self.renderer = value
.try_into()
.map_err(|e| format!("error converting supplied value for renderer: {e}"));
self
}
pub fn subject<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseSubject>,
T::Error: ::std::fmt::Display,
{
self.subject = value
.try_into()
.map_err(|e| format!("error converting supplied value for subject: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
anomalous: value.anomalous?,
claims: value.claims?,
correlation: value.correlation?,
expires_at: value.expires_at?,
ext: value.ext?,
preview_id: value.preview_id?,
renderer: value.renderer?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
anomalous: Ok(value.anomalous),
claims: Ok(value.claims),
correlation: Ok(value.correlation),
expires_at: Ok(value.expires_at),
ext: Ok(value.ext),
preview_id: Ok(value.preview_id),
renderer: Ok(value.renderer),
subject: Ok(value.subject),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseClaimsItem {
new_to_this_verifier:
::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
predicate: ::std::result::Result<
::std::option::Option<super::ResponseClaimsItemPredicate>,
::std::string::String,
>,
provenance:
::std::result::Result<super::ResponseClaimsItemProvenance, ::std::string::String>,
rung: ::std::result::Result<super::ProofRung, ::std::string::String>,
stale: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
type_: ::std::result::Result<super::ClaimType, ::std::string::String>,
value: ::std::result::Result<
::std::option::Option<::serde_json::Value>,
::std::string::String,
>,
}
impl ::std::default::Default for ResponseClaimsItem {
fn default() -> Self {
Self {
new_to_this_verifier: Ok(Default::default()),
predicate: Ok(Default::default()),
provenance: Err("no value supplied for provenance".to_string()),
rung: Err("no value supplied for rung".to_string()),
stale: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
value: Ok(Default::default()),
}
}
}
impl ResponseClaimsItem {
pub fn new_to_this_verifier<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.new_to_this_verifier = value.try_into().map_err(|e| {
format!("error converting supplied value for new_to_this_verifier: {e}")
});
self
}
pub fn predicate<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseClaimsItemPredicate>>,
T::Error: ::std::fmt::Display,
{
self.predicate = value
.try_into()
.map_err(|e| format!("error converting supplied value for predicate: {e}"));
self
}
pub fn provenance<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseClaimsItemProvenance>,
T::Error: ::std::fmt::Display,
{
self.provenance = value
.try_into()
.map_err(|e| format!("error converting supplied value for provenance: {e}"));
self
}
pub fn rung<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ProofRung>,
T::Error: ::std::fmt::Display,
{
self.rung = value
.try_into()
.map_err(|e| format!("error converting supplied value for rung: {e}"));
self
}
pub fn stale<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.stale = value
.try_into()
.map_err(|e| format!("error converting supplied value for stale: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ClaimType>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
pub fn value<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::serde_json::Value>>,
T::Error: ::std::fmt::Display,
{
self.value = value
.try_into()
.map_err(|e| format!("error converting supplied value for value: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseClaimsItem> for super::ResponseClaimsItem {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseClaimsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
new_to_this_verifier: value.new_to_this_verifier?,
predicate: value.predicate?,
provenance: value.provenance?,
rung: value.rung?,
stale: value.stale?,
type_: value.type_?,
value: value.value?,
})
}
}
impl ::std::convert::From<super::ResponseClaimsItem> for ResponseClaimsItem {
fn from(value: super::ResponseClaimsItem) -> Self {
Self {
new_to_this_verifier: Ok(value.new_to_this_verifier),
predicate: Ok(value.predicate),
provenance: Ok(value.provenance),
rung: Ok(value.rung),
stale: Ok(value.stale),
type_: Ok(value.type_),
value: Ok(value.value),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseClaimsItemPredicate {
arg: ::std::result::Result<::serde_json::Value, ::std::string::String>,
op: ::std::result::Result<super::ResponseClaimsItemPredicateOp, ::std::string::String>,
over: ::std::result::Result<::std::option::Option<super::ClaimType>, ::std::string::String>,
}
impl ::std::default::Default for ResponseClaimsItemPredicate {
fn default() -> Self {
Self {
arg: Err("no value supplied for arg".to_string()),
op: Err("no value supplied for op".to_string()),
over: Ok(Default::default()),
}
}
}
impl ResponseClaimsItemPredicate {
pub fn arg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::serde_json::Value>,
T::Error: ::std::fmt::Display,
{
self.arg = value
.try_into()
.map_err(|e| format!("error converting supplied value for arg: {e}"));
self
}
pub fn op<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseClaimsItemPredicateOp>,
T::Error: ::std::fmt::Display,
{
self.op = value
.try_into()
.map_err(|e| format!("error converting supplied value for op: {e}"));
self
}
pub fn over<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ClaimType>>,
T::Error: ::std::fmt::Display,
{
self.over = value
.try_into()
.map_err(|e| format!("error converting supplied value for over: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseClaimsItemPredicate> for super::ResponseClaimsItemPredicate {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseClaimsItemPredicate,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
arg: value.arg?,
op: value.op?,
over: value.over?,
})
}
}
impl ::std::convert::From<super::ResponseClaimsItemPredicate> for ResponseClaimsItemPredicate {
fn from(value: super::ResponseClaimsItemPredicate) -> Self {
Self {
arg: Ok(value.arg),
op: Ok(value.op),
over: Ok(value.over),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseCorrelation {
reason: ::std::result::Result<
::std::option::Option<super::ResponseCorrelationReason>,
::std::string::String,
>,
severity: ::std::result::Result<super::ResponseCorrelationSeverity, ::std::string::String>,
}
impl ::std::default::Default for ResponseCorrelation {
fn default() -> Self {
Self {
reason: Ok(Default::default()),
severity: Err("no value supplied for severity".to_string()),
}
}
}
impl ResponseCorrelation {
pub fn reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCorrelationReason>>,
T::Error: ::std::fmt::Display,
{
self.reason = value
.try_into()
.map_err(|e| format!("error converting supplied value for reason: {e}"));
self
}
pub fn severity<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseCorrelationSeverity>,
T::Error: ::std::fmt::Display,
{
self.severity = value
.try_into()
.map_err(|e| format!("error converting supplied value for severity: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseCorrelation> for super::ResponseCorrelation {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseCorrelation,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
reason: value.reason?,
severity: value.severity?,
})
}
}
impl ::std::convert::From<super::ResponseCorrelation> for ResponseCorrelation {
fn from(value: super::ResponseCorrelation) -> Self {
Self {
reason: Ok(value.reason),
severity: Ok(value.severity),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseRenderer {
drops: ::std::result::Result<
::std::vec::Vec<super::ResponseRendererDropsItem>,
::std::string::String,
>,
id: ::std::result::Result<super::ResponseRendererId, ::std::string::String>,
}
impl ::std::default::Default for ResponseRenderer {
fn default() -> Self {
Self {
drops: Err("no value supplied for drops".to_string()),
id: Err("no value supplied for id".to_string()),
}
}
}
impl ResponseRenderer {
pub fn drops<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseRendererDropsItem>>,
T::Error: ::std::fmt::Display,
{
self.drops = value
.try_into()
.map_err(|e| format!("error converting supplied value for drops: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseRendererId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseRenderer> for super::ResponseRenderer {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseRenderer,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
drops: value.drops?,
id: value.id?,
})
}
}
impl ::std::convert::From<super::ResponseRenderer> for ResponseRenderer {
fn from(value: super::ResponseRenderer) -> Self {
Self {
drops: Ok(value.drops),
id: Ok(value.id),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/disclosure/preview/1.0";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"ClaimType\": {\n \"description\": \"The vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.\\n\\nThe token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.\\n\\nThe `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"pattern\": \"^(x:)?[a-z][a-zA-Z0-9]*(\\\\.[a-z][a-zA-Z0-9]*)*$\",\n \"title\": \"ClaimType\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"ProofRung\": {\n \"description\": \"How strongly a credential-backed claim is hidden when presented, ordered most private first. `predicate` proves a statement over a claim without disclosing the claim. `derived` discloses exactly the claims needed via an unlinkable derived proof, so two presentations cannot be joined. `selectiveDisclosure` discloses exactly the claims needed but carries the issuer's signature unchanged, so two presentations ARE linkable. `whole` discloses the entire credential.\\n\\nThe distinction between the first two and the last two is of kind, not degree: only `predicate` and `derived` avoid handing two verifiers a join key. A maintainer MUST default to the highest rung the credential's format supports, and MUST NOT silently fall to a lower one — a request that cannot be satisfied at the rung a producer asked for is refused, because a silent privacy downgrade discloses material the holder believed was hidden.\",\n \"enum\": [\n \"predicate\",\n \"derived\",\n \"selectiveDisclosure\",\n \"whole\"\n ],\n \"title\": \"ProofRung\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to persona/disclosure/preview. Type https://trusttasks.org/spec/persona/disclosure/preview/1.0#response. Signs nothing and sends nothing. The `previewId` returned here is consumed by persona/disclosure/present, which is the mechanism by which the two calls cannot be collapsed.\",\n \"properties\": {\n \"anomalous\": {\n \"description\": \"Claim types unusual for this verifier's stated purpose. A preview that lists fourteen fields with fourteen equal weights is a notice-and-consent dialog, which is the pattern that trains people to click through; ranking by what is out of place is what makes the surfaced line the one worth reading.\",\n \"items\": {\n \"$ref\": \"#/$defs/ClaimType\"\n },\n \"maxItems\": 128,\n \"type\": \"array\"\n },\n \"claims\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"newToThisVerifier\": {\n \"description\": \"True when this verifier has not previously received this claim type from this persona. What makes a preview rankable rather than a flat list — a holder needs the unusual ask to stand out from the routine one.\",\n \"type\": \"boolean\"\n },\n \"predicate\": {\n \"additionalProperties\": false,\n \"description\": \"Present instead of `value` when the claim would be proven rather than shown, e.g. that a date of birth implies an age threshold. The underlying attribute stays in the pool; the predicate is a disclosure-time projection over it, which is what keeps the pool from filling with derived facts that are all the same fact asked differently.\",\n \"properties\": {\n \"arg\": {},\n \"op\": {\n \"enum\": [\n \"gte\",\n \"gt\",\n \"lte\",\n \"lt\",\n \"eq\",\n \"ne\",\n \"memberOf\"\n ],\n \"type\": \"string\"\n },\n \"over\": {\n \"$ref\": \"#/$defs/ClaimType\"\n }\n },\n \"required\": [\n \"op\",\n \"arg\"\n ],\n \"type\": \"object\"\n },\n \"provenance\": {\n \"enum\": [\n \"selfAsserted\",\n \"credentialBacked\",\n \"generated\",\n \"derived\"\n ],\n \"type\": \"string\"\n },\n \"rung\": {\n \"$ref\": \"#/$defs/ProofRung\"\n },\n \"stale\": {\n \"description\": \"True when a credential-backed claim could not be re-derived. Such a claim MUST NOT be disclosed; it is shown in the preview so the holder learns why the disclosure will be short.\",\n \"type\": \"boolean\"\n },\n \"type\": {\n \"$ref\": \"#/$defs/ClaimType\"\n },\n \"value\": {\n \"description\": \"What would be disclosed. Absent for a predicate claim, which discloses no value at all — that absence is the point and a consumer MUST NOT render it as missing data.\"\n }\n },\n \"required\": [\n \"type\",\n \"provenance\",\n \"rung\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 128,\n \"type\": \"array\"\n },\n \"correlation\": {\n \"additionalProperties\": false,\n \"description\": \"How much this disclosure would link the holder. Note the inversion that is easy to get backwards: a credential presented WHOLE correlates more than a self-asserted value, because the issuer signature is identical at every verifier — while a derived proof correlates LESS, because it differs on every presentation. Severity is therefore a function of value and rung together, not of provenance alone.\",\n \"properties\": {\n \"reason\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"severity\": {\n \"enum\": [\n \"none\",\n \"low\",\n \"high\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"severity\"\n ],\n \"type\": \"object\"\n },\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"previewId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"Consumed by present. Single-use and short-lived: a preview a holder approved an hour ago is not evidence they approve it now, and one that could be replayed would let a second disclosure ride an earlier decision.\"\n },\n \"renderer\": {\n \"additionalProperties\": false,\n \"description\": \"The output format and, crucially, what it cannot carry. Lossiness is DECLARED rather than discovered: a holder is owed 'this verifier will see your work number but not that your employer attested it' before deciding, not after.\",\n \"properties\": {\n \"drops\": {\n \"description\": \"What this renderer discards — commonly provenance. Empty for a lossless renderer.\",\n \"items\": {\n \"maxLength\": 64,\n \"type\": \"string\"\n },\n \"maxItems\": 32,\n \"type\": \"array\"\n },\n \"id\": {\n \"maxLength\": 64,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"drops\"\n ],\n \"type\": \"object\"\n },\n \"subject\": {\n \"description\": \"The identifier that would appear as the subject of the disclosure. Pairwise by default — a fresh per-relationship DID rather than the persona DID — so that two verifiers cannot recognise the holder as the same party. The persona DID is the account; this is the face.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"previewId\",\n \"subject\",\n \"claims\",\n \"expiresAt\"\n ],\n \"title\": \"Persona Disclosure Preview — response payload\",\n \"type\": \"object\"\n },\n \"Ulid\": {\n \"description\": \"A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.\",\n \"pattern\": \"^[0-9A-HJKMNP-TV-Z]{26}$\",\n \"title\": \"Ulid\",\n \"type\": \"string\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/persona/disclosure/preview/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Determine exactly what a disclosure would reveal, and to whom, without signing or sending anything. The first of two calls that cannot be collapsed: there is no path to a disclosure that did not first produce the summary a human can be shown.\",\n \"properties\": {\n \"contextId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"personaDid\": {\n \"description\": \"The persona that would present. Its binding supplies the profile.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"purpose\": {\n \"description\": \"The verifier's stated reason, carried through to the preview and the disclosure record so a holder deciding later has the same context as one deciding now.\",\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"renderer\": {\n \"description\": \"Which output format to prepare for. Omit for the maintainer's canonical form. The choice matters to the preview because renderers differ in what they can carry, and a holder is owed that before deciding.\",\n \"maxLength\": 64,\n \"type\": \"string\"\n },\n \"requestedClaims\": {\n \"description\": \"Claim types the verifier asked for. Omit to preview everything the bound profile would present. A maintainer MUST NOT return a claim that was not requested when this member is present — narrowing is the caller's to ask for and the maintainer's to honour.\",\n \"items\": {\n \"$ref\": \"#/$defs/ClaimType\"\n },\n \"maxItems\": 128,\n \"type\": \"array\"\n },\n \"verifierDid\": {\n \"description\": \"Who would receive it. Required, and not optional, because half of what a preview says is who is asking — a preview that could not name the recipient would be a list of fields rather than a decision.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"contextId\",\n \"personaDid\",\n \"verifierDid\"\n ],\n \"title\": \"Persona Disclosure Preview — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/persona/disclosure/preview/1.0#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"ClaimType\": {\n \"description\": \"The vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.\\n\\nThe token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.\\n\\nThe `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"pattern\": \"^(x:)?[a-z][a-zA-Z0-9]*(\\\\.[a-z][a-zA-Z0-9]*)*$\",\n \"title\": \"ClaimType\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"ProofRung\": {\n \"description\": \"How strongly a credential-backed claim is hidden when presented, ordered most private first. `predicate` proves a statement over a claim without disclosing the claim. `derived` discloses exactly the claims needed via an unlinkable derived proof, so two presentations cannot be joined. `selectiveDisclosure` discloses exactly the claims needed but carries the issuer's signature unchanged, so two presentations ARE linkable. `whole` discloses the entire credential.\\n\\nThe distinction between the first two and the last two is of kind, not degree: only `predicate` and `derived` avoid handing two verifiers a join key. A maintainer MUST default to the highest rung the credential's format supports, and MUST NOT silently fall to a lower one — a request that cannot be satisfied at the rung a producer asked for is refused, because a silent privacy downgrade discloses material the holder believed was hidden.\",\n \"enum\": [\n \"predicate\",\n \"derived\",\n \"selectiveDisclosure\",\n \"whole\"\n ],\n \"title\": \"ProofRung\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to persona/disclosure/preview. Type https://trusttasks.org/spec/persona/disclosure/preview/1.0#response. Signs nothing and sends nothing. The `previewId` returned here is consumed by persona/disclosure/present, which is the mechanism by which the two calls cannot be collapsed.\",\n \"properties\": {\n \"anomalous\": {\n \"description\": \"Claim types unusual for this verifier's stated purpose. A preview that lists fourteen fields with fourteen equal weights is a notice-and-consent dialog, which is the pattern that trains people to click through; ranking by what is out of place is what makes the surfaced line the one worth reading.\",\n \"items\": {\n \"$ref\": \"#/$defs/ClaimType\"\n },\n \"maxItems\": 128,\n \"type\": \"array\"\n },\n \"claims\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"newToThisVerifier\": {\n \"description\": \"True when this verifier has not previously received this claim type from this persona. What makes a preview rankable rather than a flat list — a holder needs the unusual ask to stand out from the routine one.\",\n \"type\": \"boolean\"\n },\n \"predicate\": {\n \"additionalProperties\": false,\n \"description\": \"Present instead of `value` when the claim would be proven rather than shown, e.g. that a date of birth implies an age threshold. The underlying attribute stays in the pool; the predicate is a disclosure-time projection over it, which is what keeps the pool from filling with derived facts that are all the same fact asked differently.\",\n \"properties\": {\n \"arg\": {},\n \"op\": {\n \"enum\": [\n \"gte\",\n \"gt\",\n \"lte\",\n \"lt\",\n \"eq\",\n \"ne\",\n \"memberOf\"\n ],\n \"type\": \"string\"\n },\n \"over\": {\n \"$ref\": \"#/$defs/ClaimType\"\n }\n },\n \"required\": [\n \"op\",\n \"arg\"\n ],\n \"type\": \"object\"\n },\n \"provenance\": {\n \"enum\": [\n \"selfAsserted\",\n \"credentialBacked\",\n \"generated\",\n \"derived\"\n ],\n \"type\": \"string\"\n },\n \"rung\": {\n \"$ref\": \"#/$defs/ProofRung\"\n },\n \"stale\": {\n \"description\": \"True when a credential-backed claim could not be re-derived. Such a claim MUST NOT be disclosed; it is shown in the preview so the holder learns why the disclosure will be short.\",\n \"type\": \"boolean\"\n },\n \"type\": {\n \"$ref\": \"#/$defs/ClaimType\"\n },\n \"value\": {\n \"description\": \"What would be disclosed. Absent for a predicate claim, which discloses no value at all — that absence is the point and a consumer MUST NOT render it as missing data.\"\n }\n },\n \"required\": [\n \"type\",\n \"provenance\",\n \"rung\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 128,\n \"type\": \"array\"\n },\n \"correlation\": {\n \"additionalProperties\": false,\n \"description\": \"How much this disclosure would link the holder. Note the inversion that is easy to get backwards: a credential presented WHOLE correlates more than a self-asserted value, because the issuer signature is identical at every verifier — while a derived proof correlates LESS, because it differs on every presentation. Severity is therefore a function of value and rung together, not of provenance alone.\",\n \"properties\": {\n \"reason\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"severity\": {\n \"enum\": [\n \"none\",\n \"low\",\n \"high\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"severity\"\n ],\n \"type\": \"object\"\n },\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"previewId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"Consumed by present. Single-use and short-lived: a preview a holder approved an hour ago is not evidence they approve it now, and one that could be replayed would let a second disclosure ride an earlier decision.\"\n },\n \"renderer\": {\n \"additionalProperties\": false,\n \"description\": \"The output format and, crucially, what it cannot carry. Lossiness is DECLARED rather than discovered: a holder is owed 'this verifier will see your work number but not that your employer attested it' before deciding, not after.\",\n \"properties\": {\n \"drops\": {\n \"description\": \"What this renderer discards — commonly provenance. Empty for a lossless renderer.\",\n \"items\": {\n \"maxLength\": 64,\n \"type\": \"string\"\n },\n \"maxItems\": 32,\n \"type\": \"array\"\n },\n \"id\": {\n \"maxLength\": 64,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"drops\"\n ],\n \"type\": \"object\"\n },\n \"subject\": {\n \"description\": \"The identifier that would appear as the subject of the disclosure. Pairwise by default — a fresh per-relationship DID rather than the persona DID — so that two verifiers cannot recognise the holder as the same party. The persona DID is the account; this is the face.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"previewId\",\n \"subject\",\n \"claims\",\n \"expiresAt\"\n ],\n \"title\": \"Persona Disclosure Preview — response payload\",\n \"type\": \"object\"\n },\n \"Ulid\": {\n \"description\": \"A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.\",\n \"pattern\": \"^[0-9A-HJKMNP-TV-Z]{26}$\",\n \"title\": \"Ulid\",\n \"type\": \"string\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::NOT_BOUND,
error_codes::RENDERER_UNAVAILABLE,
error_codes::RENDERER_CANNOT_CARRY,
];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `persona/disclosure/preview:notBound`
///
/// The persona has no profile bound, so there is nothing to disclose. A normal condition rather than a fault — a persona need not have a profile.
///
/// Declared `retryable: false`.
pub const NOT_BOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/disclosure/preview:notBound",
retryable: false,
};
/// `persona/disclosure/preview:rendererUnavailable`
///
/// The requested renderer is not offered by this maintainer. The available renderers are enumerable, so a producer discovers rather than guesses.
///
/// Declared `retryable: false`.
pub const RENDERER_UNAVAILABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/disclosure/preview:rendererUnavailable",
retryable: false,
};
/// `persona/disclosure/preview:rendererCannotCarry`
///
/// The requested renderer cannot represent a claim in the disclosure — most commonly a predicate, which has no value to render. Failing here at format negotiation is deliberate; silently dropping the claim would produce a disclosure that verifies and says less than the holder approved.
///
/// Declared `retryable: false`.
pub const RENDERER_CANNOT_CARRY: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/disclosure/preview:rendererCannotCarry",
retryable: false,
};
}