//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/credentials/list`. Version: `0.1`.
#[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())
}
}
}
///Stable identifier for an issued credential — the handle for revocation and audit. Opaque to the holder: it MUST be echoed verbatim when revoking and MUST NOT be parsed.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "CredentialId",
/// "description": "Stable identifier for an issued credential — the handle for revocation and audit. Opaque to the holder: it MUST be echoed verbatim when revoking and MUST NOT be parsed.",
/// "type": "string",
/// "minLength": 1,
/// "$anchor": "credentialId"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CredentialId(::std::string::String);
impl ::std::ops::Deref for CredentialId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CredentialId> for ::std::string::String {
fn from(value: CredentialId) -> Self {
value.0
}
}
impl ::std::str::FromStr for CredentialId {
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 CredentialId {
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 CredentialId {
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 CredentialId {
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 CredentialId {
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())
})
}
}
///`Did`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "pattern": "^did:[a-z0-9]+:.+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Did(::std::string::String);
impl ::std::ops::Deref for Did {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Did> for ::std::string::String {
fn from(value: Did) -> Self {
value.0
}
}
impl ::std::str::FromStr for Did {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^did:[a-z0-9]+:.+$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:[a-z0-9]+:.+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Did {
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 Did {
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 Did {
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 Did {
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())
})
}
}
///Derived at read time. `revoked` takes precedence over `expired`: a credential revoked before its window closed is revoked, and reporting it as merely expired would hide that somebody acted.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Derived at read time. `revoked` takes precedence over `expired`: a credential revoked before its window closed is revoked, and reporting it as merely expired would hide that somebody acted.",
/// "type": "string",
/// "enum": [
/// "active",
/// "expired",
/// "revoked"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum IssuedCredentialStatus {
#[serde(rename = "active")]
Active,
#[serde(rename = "expired")]
Expired,
#[serde(rename = "revoked")]
Revoked,
}
impl ::std::fmt::Display for IssuedCredentialStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Active => f.write_str("active"),
Self::Expired => f.write_str("expired"),
Self::Revoked => f.write_str("revoked"),
}
}
}
impl ::std::str::FromStr for IssuedCredentialStatus {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"active" => Ok(Self::Active),
"expired" => Ok(Self::Expired),
"revoked" => Ok(Self::Revoked),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for IssuedCredentialStatus {
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 IssuedCredentialStatus {
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 IssuedCredentialStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A body-free projection of an issuance record. Carries no claim content by construction — see the specification's rationale for why a list does not return credentials.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "IssuedCredentialSummary",
/// "description": "A body-free projection of an issuance record. Carries no claim content by construction — see the specification's rationale for why a list does not return credentials.",
/// "type": "object",
/// "required": [
/// "credentialId",
/// "expiresAt",
/// "holder",
/// "issuedAt",
/// "status"
/// ],
/// "properties": {
/// "credentialId": {
/// "description": "The id `vta/credentials/revoke` is keyed on.",
/// "$ref": "#/definitions/CredentialId"
/// },
/// "credentialType": {
/// "description": "The type tag beyond `VerifiableCredential`, when the credential carries one.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "expiresAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "holder": {
/// "description": "Who the credential was issued to.",
/// "$ref": "#/definitions/Did"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "revocationReason": {
/// "description": "Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.",
/// "type": "string",
/// "maxLength": 1024
/// },
/// "revokedAt": {
/// "description": "Present iff `status` is `revoked`.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "status": {
/// "$ref": "#/definitions/IssuedCredentialStatus"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct IssuedCredentialSummary {
///The id `vta/credentials/revoke` is keyed on.
#[serde(rename = "credentialId")]
pub credential_id: CredentialId,
///The type tag beyond `VerifiableCredential`, when the credential carries one.
#[serde(
rename = "credentialType",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub credential_type: ::std::option::Option<IssuedCredentialSummaryCredentialType>,
#[serde(rename = "expiresAt")]
pub expires_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Who the credential was issued to.
pub holder: Did,
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.
#[serde(
rename = "revocationReason",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub revocation_reason: ::std::option::Option<IssuedCredentialSummaryRevocationReason>,
///Present iff `status` is `revoked`.
#[serde(
rename = "revokedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub revoked_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
pub status: IssuedCredentialStatus,
}
impl IssuedCredentialSummary {
pub fn builder() -> builder::IssuedCredentialSummary {
Default::default()
}
}
///The type tag beyond `VerifiableCredential`, when the credential carries one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The type tag beyond `VerifiableCredential`, when the credential carries one.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct IssuedCredentialSummaryCredentialType(::std::string::String);
impl ::std::ops::Deref for IssuedCredentialSummaryCredentialType {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<IssuedCredentialSummaryCredentialType> for ::std::string::String {
fn from(value: IssuedCredentialSummaryCredentialType) -> Self {
value.0
}
}
impl ::std::str::FromStr for IssuedCredentialSummaryCredentialType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 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 IssuedCredentialSummaryCredentialType {
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 IssuedCredentialSummaryCredentialType {
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 IssuedCredentialSummaryCredentialType {
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 IssuedCredentialSummaryCredentialType {
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())
})
}
}
///Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.",
/// "type": "string",
/// "maxLength": 1024
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct IssuedCredentialSummaryRevocationReason(::std::string::String);
impl ::std::ops::Deref for IssuedCredentialSummaryRevocationReason {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<IssuedCredentialSummaryRevocationReason> for ::std::string::String {
fn from(value: IssuedCredentialSummaryRevocationReason) -> Self {
value.0
}
}
impl ::std::str::FromStr for IssuedCredentialSummaryRevocationReason {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for IssuedCredentialSummaryRevocationReason {
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 IssuedCredentialSummaryRevocationReason {
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 IssuedCredentialSummaryRevocationReason {
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 IssuedCredentialSummaryRevocationReason {
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())
})
}
}
///Enumerate the credentials an agent has issued, as metadata. Every filter is optional and those present are AND-combined.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/credentials/list/0.1",
/// "title": "Payload",
/// "description": "Enumerate the credentials an agent has issued, as metadata. Every filter is optional and those present are AND-combined.",
/// "type": "object",
/// "properties": {
/// "credentialType": {
/// "description": "Only credentials carrying this type tag beyond `VerifiableCredential`.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "cursor": {
/// "description": "Continue a previous page. Opaque — consumers must not construct or parse one.",
/// "type": "string",
/// "maxLength": 4096,
/// "minLength": 1
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "holder": {
/// "description": "Only credentials issued to this DID.",
/// "$ref": "#/definitions/Did"
/// },
/// "pageSize": {
/// "description": "Maximum records to return. The agent MAY return fewer and caps this value.",
/// "type": "integer",
/// "maximum": 1000.0,
/// "minimum": 1.0
/// },
/// "status": {
/// "description": "Only credentials in this state. Derived by the agent at read time, never stored.",
/// "$ref": "#/definitions/IssuedCredentialStatus"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Only credentials carrying this type tag beyond `VerifiableCredential`.
#[serde(
rename = "credentialType",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub credential_type: ::std::option::Option<PayloadCredentialType>,
///Continue a previous page. Opaque — consumers must not construct or parse one.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<PayloadCursor>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Only credentials issued to this DID.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub holder: ::std::option::Option<Did>,
///Maximum records to return. The agent MAY return fewer and caps this value.
#[serde(
rename = "pageSize",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub page_size: ::std::option::Option<::std::num::NonZeroU64>,
///Only credentials in this state. Derived by the agent at read time, never stored.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<IssuedCredentialStatus>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
credential_type: Default::default(),
cursor: Default::default(),
ext: Default::default(),
holder: Default::default(),
page_size: Default::default(),
status: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Only credentials carrying this type tag beyond `VerifiableCredential`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Only credentials carrying this type tag beyond `VerifiableCredential`.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCredentialType(::std::string::String);
impl ::std::ops::Deref for PayloadCredentialType {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCredentialType> for ::std::string::String {
fn from(value: PayloadCredentialType) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCredentialType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 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 PayloadCredentialType {
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 PayloadCredentialType {
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 PayloadCredentialType {
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 PayloadCredentialType {
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())
})
}
}
///Continue a previous page. Opaque — consumers must not construct or parse one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Continue a previous page. Opaque — consumers must not construct or parse one.",
/// "type": "string",
/// "maxLength": 4096,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCursor(::std::string::String);
impl ::std::ops::Deref for PayloadCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCursor> for ::std::string::String {
fn from(value: PayloadCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCursor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 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 PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "credentials",
/// "truncated"
/// ],
/// "properties": {
/// "credentials": {
/// "description": "One summary per matching credential. Empty when nothing matched — a successful answer, not an error.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/IssuedCredentialSummary"
/// }
/// },
/// "cursor": {
/// "description": "Pass to the next request to continue. Absent when the page is the last.",
/// "type": "string",
/// "maxLength": 4096,
/// "minLength": 1
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "truncated": {
/// "description": "The agent stopped early. A consumer must not read a truncated page as a complete account of what was issued.",
/// "type": "boolean"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///One summary per matching credential. Empty when nothing matched — a successful answer, not an error.
pub credentials: ::std::vec::Vec<IssuedCredentialSummary>,
///Pass to the next request to continue. Absent when the page is the last.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<ResponseCursor>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The agent stopped early. A consumer must not read a truncated page as a complete account of what was issued.
pub truncated: bool,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Pass to the next request to continue. Absent when the page is the last.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Pass to the next request to continue. Absent when the page is the last.",
/// "type": "string",
/// "maxLength": 4096,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseCursor(::std::string::String);
impl ::std::ops::Deref for ResponseCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseCursor> for ::std::string::String {
fn from(value: ResponseCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseCursor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 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 ResponseCursor {
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 ResponseCursor {
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 ResponseCursor {
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 ResponseCursor {
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 IssuedCredentialSummary {
credential_id: ::std::result::Result<super::CredentialId, ::std::string::String>,
credential_type: ::std::result::Result<
::std::option::Option<super::IssuedCredentialSummaryCredentialType>,
::std::string::String,
>,
expires_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
holder: ::std::result::Result<super::Did, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
revocation_reason: ::std::result::Result<
::std::option::Option<super::IssuedCredentialSummaryRevocationReason>,
::std::string::String,
>,
revoked_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
status: ::std::result::Result<super::IssuedCredentialStatus, ::std::string::String>,
}
impl ::std::default::Default for IssuedCredentialSummary {
fn default() -> Self {
Self {
credential_id: Err("no value supplied for credential_id".to_string()),
credential_type: Ok(Default::default()),
expires_at: Err("no value supplied for expires_at".to_string()),
holder: Err("no value supplied for holder".to_string()),
issued_at: Err("no value supplied for issued_at".to_string()),
revocation_reason: Ok(Default::default()),
revoked_at: Ok(Default::default()),
status: Err("no value supplied for status".to_string()),
}
}
}
impl IssuedCredentialSummary {
pub fn credential_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CredentialId>,
T::Error: ::std::fmt::Display,
{
self.credential_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for credential_id: {e}"));
self
}
pub fn credential_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::IssuedCredentialSummaryCredentialType>,
>,
T::Error: ::std::fmt::Display,
{
self.credential_type = value
.try_into()
.map_err(|e| format!("error converting supplied value for credential_type: {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 holder<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Did>,
T::Error: ::std::fmt::Display,
{
self.holder = value
.try_into()
.map_err(|e| format!("error converting supplied value for holder: {e}"));
self
}
pub fn issued_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.issued_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for issued_at: {e}"));
self
}
pub fn revocation_reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::IssuedCredentialSummaryRevocationReason>,
>,
T::Error: ::std::fmt::Display,
{
self.revocation_reason = value
.try_into()
.map_err(|e| format!("error converting supplied value for revocation_reason: {e}"));
self
}
pub fn revoked_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.revoked_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for revoked_at: {e}"));
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::IssuedCredentialStatus>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
}
impl ::std::convert::TryFrom<IssuedCredentialSummary> for super::IssuedCredentialSummary {
type Error = super::error::ConversionError;
fn try_from(
value: IssuedCredentialSummary,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
credential_id: value.credential_id?,
credential_type: value.credential_type?,
expires_at: value.expires_at?,
holder: value.holder?,
issued_at: value.issued_at?,
revocation_reason: value.revocation_reason?,
revoked_at: value.revoked_at?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::IssuedCredentialSummary> for IssuedCredentialSummary {
fn from(value: super::IssuedCredentialSummary) -> Self {
Self {
credential_id: Ok(value.credential_id),
credential_type: Ok(value.credential_type),
expires_at: Ok(value.expires_at),
holder: Ok(value.holder),
issued_at: Ok(value.issued_at),
revocation_reason: Ok(value.revocation_reason),
revoked_at: Ok(value.revoked_at),
status: Ok(value.status),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
credential_type: ::std::result::Result<
::std::option::Option<super::PayloadCredentialType>,
::std::string::String,
>,
cursor: ::std::result::Result<
::std::option::Option<super::PayloadCursor>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
holder: ::std::result::Result<::std::option::Option<super::Did>, ::std::string::String>,
page_size: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::IssuedCredentialStatus>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
credential_type: Ok(Default::default()),
cursor: Ok(Default::default()),
ext: Ok(Default::default()),
holder: Ok(Default::default()),
page_size: Ok(Default::default()),
status: Ok(Default::default()),
}
}
}
impl Payload {
pub fn credential_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadCredentialType>>,
T::Error: ::std::fmt::Display,
{
self.credential_type = value
.try_into()
.map_err(|e| format!("error converting supplied value for credential_type: {e}"));
self
}
pub fn cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadCursor>>,
T::Error: ::std::fmt::Display,
{
self.cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for cursor: {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 holder<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Did>>,
T::Error: ::std::fmt::Display,
{
self.holder = value
.try_into()
.map_err(|e| format!("error converting supplied value for holder: {e}"));
self
}
pub fn page_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.page_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for page_size: {e}"));
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::IssuedCredentialStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {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 {
credential_type: value.credential_type?,
cursor: value.cursor?,
ext: value.ext?,
holder: value.holder?,
page_size: value.page_size?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
credential_type: Ok(value.credential_type),
cursor: Ok(value.cursor),
ext: Ok(value.ext),
holder: Ok(value.holder),
page_size: Ok(value.page_size),
status: Ok(value.status),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
credentials: ::std::result::Result<
::std::vec::Vec<super::IssuedCredentialSummary>,
::std::string::String,
>,
cursor: ::std::result::Result<
::std::option::Option<super::ResponseCursor>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
truncated: ::std::result::Result<bool, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
credentials: Err("no value supplied for credentials".to_string()),
cursor: Ok(Default::default()),
ext: Ok(Default::default()),
truncated: Err("no value supplied for truncated".to_string()),
}
}
}
impl Response {
pub fn credentials<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::IssuedCredentialSummary>>,
T::Error: ::std::fmt::Display,
{
self.credentials = value
.try_into()
.map_err(|e| format!("error converting supplied value for credentials: {e}"));
self
}
pub fn cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCursor>>,
T::Error: ::std::fmt::Display,
{
self.cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for cursor: {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 truncated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.truncated = value
.try_into()
.map_err(|e| format!("error converting supplied value for truncated: {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 {
credentials: value.credentials?,
cursor: value.cursor?,
ext: value.ext?,
truncated: value.truncated?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
credentials: Ok(value.credentials),
cursor: Ok(value.cursor),
ext: Ok(value.ext),
truncated: Ok(value.truncated),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/credentials/list/0.1";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"CredentialId\": {\n \"$anchor\": \"credentialId\",\n \"description\": \"Stable identifier for an issued credential — the handle for revocation and audit. Opaque to the holder: it MUST be echoed verbatim when revoking and MUST NOT be parsed.\",\n \"minLength\": 1,\n \"title\": \"CredentialId\",\n \"type\": \"string\"\n },\n \"Did\": {\n \"maxLength\": 2048,\n \"pattern\": \"^did:[a-z0-9]+:.+$\",\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 \"IssuedCredentialStatus\": {\n \"description\": \"Derived at read time. `revoked` takes precedence over `expired`: a credential revoked before its window closed is revoked, and reporting it as merely expired would hide that somebody acted.\",\n \"enum\": [\n \"active\",\n \"expired\",\n \"revoked\"\n ],\n \"type\": \"string\"\n },\n \"IssuedCredentialSummary\": {\n \"additionalProperties\": false,\n \"description\": \"A body-free projection of an issuance record. Carries no claim content by construction — see the specification's rationale for why a list does not return credentials.\",\n \"properties\": {\n \"credentialId\": {\n \"$ref\": \"#/$defs/CredentialId\",\n \"description\": \"The id `vta/credentials/revoke` is keyed on.\"\n },\n \"credentialType\": {\n \"description\": \"The type tag beyond `VerifiableCredential`, when the credential carries one.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"holder\": {\n \"$ref\": \"#/$defs/Did\",\n \"description\": \"Who the credential was issued to.\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"revocationReason\": {\n \"description\": \"Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.\",\n \"maxLength\": 1024,\n \"type\": \"string\"\n },\n \"revokedAt\": {\n \"description\": \"Present iff `status` is `revoked`.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"status\": {\n \"$ref\": \"#/$defs/IssuedCredentialStatus\"\n }\n },\n \"required\": [\n \"credentialId\",\n \"holder\",\n \"issuedAt\",\n \"expiresAt\",\n \"status\"\n ],\n \"title\": \"IssuedCredentialSummary\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"credentials\": {\n \"description\": \"One summary per matching credential. Empty when nothing matched — a successful answer, not an error.\",\n \"items\": {\n \"$ref\": \"#/$defs/IssuedCredentialSummary\"\n },\n \"type\": \"array\"\n },\n \"cursor\": {\n \"description\": \"Pass to the next request to continue. Absent when the page is the last.\",\n \"maxLength\": 4096,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"truncated\": {\n \"description\": \"The agent stopped early. A consumer must not read a truncated page as a complete account of what was issued.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"credentials\",\n \"truncated\"\n ],\n \"title\": \"VTA Credentials List — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vta/credentials/list/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Enumerate the credentials an agent has issued, as metadata. Every filter is optional and those present are AND-combined.\",\n \"properties\": {\n \"credentialType\": {\n \"description\": \"Only credentials carrying this type tag beyond `VerifiableCredential`.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"cursor\": {\n \"description\": \"Continue a previous page. Opaque — consumers must not construct or parse one.\",\n \"maxLength\": 4096,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"holder\": {\n \"$ref\": \"#/$defs/Did\",\n \"description\": \"Only credentials issued to this DID.\"\n },\n \"pageSize\": {\n \"description\": \"Maximum records to return. The agent MAY return fewer and caps this value.\",\n \"maximum\": 1000,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"status\": {\n \"$ref\": \"#/$defs/IssuedCredentialStatus\",\n \"description\": \"Only credentials in this state. Derived by the agent at read time, never stored.\"\n }\n },\n \"title\": \"VTA Credentials — List\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/credentials/list/0.1#response";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"CredentialId\": {\n \"$anchor\": \"credentialId\",\n \"description\": \"Stable identifier for an issued credential — the handle for revocation and audit. Opaque to the holder: it MUST be echoed verbatim when revoking and MUST NOT be parsed.\",\n \"minLength\": 1,\n \"title\": \"CredentialId\",\n \"type\": \"string\"\n },\n \"Did\": {\n \"maxLength\": 2048,\n \"pattern\": \"^did:[a-z0-9]+:.+$\",\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 \"IssuedCredentialStatus\": {\n \"description\": \"Derived at read time. `revoked` takes precedence over `expired`: a credential revoked before its window closed is revoked, and reporting it as merely expired would hide that somebody acted.\",\n \"enum\": [\n \"active\",\n \"expired\",\n \"revoked\"\n ],\n \"type\": \"string\"\n },\n \"IssuedCredentialSummary\": {\n \"additionalProperties\": false,\n \"description\": \"A body-free projection of an issuance record. Carries no claim content by construction — see the specification's rationale for why a list does not return credentials.\",\n \"properties\": {\n \"credentialId\": {\n \"$ref\": \"#/$defs/CredentialId\",\n \"description\": \"The id `vta/credentials/revoke` is keyed on.\"\n },\n \"credentialType\": {\n \"description\": \"The type tag beyond `VerifiableCredential`, when the credential carries one.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"holder\": {\n \"$ref\": \"#/$defs/Did\",\n \"description\": \"Who the credential was issued to.\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"revocationReason\": {\n \"description\": \"Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.\",\n \"maxLength\": 1024,\n \"type\": \"string\"\n },\n \"revokedAt\": {\n \"description\": \"Present iff `status` is `revoked`.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"status\": {\n \"$ref\": \"#/$defs/IssuedCredentialStatus\"\n }\n },\n \"required\": [\n \"credentialId\",\n \"holder\",\n \"issuedAt\",\n \"expiresAt\",\n \"status\"\n ],\n \"title\": \"IssuedCredentialSummary\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"credentials\": {\n \"description\": \"One summary per matching credential. Empty when nothing matched — a successful answer, not an error.\",\n \"items\": {\n \"$ref\": \"#/$defs/IssuedCredentialSummary\"\n },\n \"type\": \"array\"\n },\n \"cursor\": {\n \"description\": \"Pass to the next request to continue. Absent when the page is the last.\",\n \"maxLength\": 4096,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"truncated\": {\n \"description\": \"The agent stopped early. A consumer must not read a truncated page as a complete account of what was issued.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"credentials\",\n \"truncated\"\n ],\n \"title\": \"VTA Credentials List — response payload\",\n \"type\": \"object\"\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;
}
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
#[test]
fn request_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:00000000-0000-4000-8000-000000000001\",\n \"type\": \"https://trusttasks.org/spec/vta/credentials/list/0.1#request\",\n \"issuer\": \"did:example:administrator\",\n \"recipient\": \"did:example:agent\",\n \"issuedAt\": \"2026-01-01T00:00:00Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000ff\",\n \"payload\": {\n \"holder\": \"did:example:holder\",\n \"status\": \"active\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn response_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:00000000-0000-4000-8000-000000000002\",\n \"type\": \"https://trusttasks.org/spec/vta/credentials/list/0.1#response\",\n \"issuer\": \"did:example:agent\",\n \"recipient\": \"did:example:administrator\",\n \"issuedAt\": \"2026-01-01T00:00:01Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000ff\",\n \"payload\": {\n \"credentials\": [\n {\n \"credentialId\": \"urn:uuid:11111111-1111-4111-8111-111111111111\",\n \"holder\": \"did:example:holder\",\n \"credentialType\": \"MembershipCredential\",\n \"issuedAt\": \"2026-01-01T00:00:00Z\",\n \"expiresAt\": \"2027-01-01T00:00:00Z\",\n \"status\": \"active\"\n },\n {\n \"credentialId\": \"urn:uuid:22222222-2222-4222-8222-222222222222\",\n \"holder\": \"did:example:holder\",\n \"credentialType\": \"RoleCredential\",\n \"issuedAt\": \"2025-06-01T00:00:00Z\",\n \"expiresAt\": \"2027-06-01T00:00:00Z\",\n \"status\": \"revoked\",\n \"revokedAt\": \"2026-02-14T09:30:00Z\",\n \"revocationReason\": \"role ended\"\n }\n ],\n \"truncated\": false\n }\n}\n";
let doc: crate::TrustTask<super::Response> =
serde_json::from_str(JSON).expect("deserialize response example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "response example failed round-trip");
}
/// Each fixture in `payload.invalid-examples.json` MUST be
/// rejected by at least one of: serde deserialization, or
/// JSON-Schema validation under the `validate` feature. The
/// fixture file documents the producer-side bug class that
/// each payload exemplifies; this generated test pins it.
#[cfg(feature = "validate")]
#[test]
fn rejects_invalid_examples() {
use crate::validate::ValidatedPayload;
let fixtures: &[(&str, &str)] = &[
(
"Unknown top-level member — additionalProperties: false catches `includeBodies`. A list never returns credential bodies, so a member asking for them must not silently be ignored.",
"{\n \"includeBodies\": true\n}",
),
(
"status outside the derived enum. `suspended` is not a state this task computes, and admitting it would let a consumer filter on something no agent can answer.",
"{\n \"status\": \"suspended\"\n}",
),
("holder that is not a DID.", "{\n \"holder\": \"holder@example.com\"\n}"),
(
"pageSize of zero. A page of nothing is not a page, and minimum: 1 refuses the shape that would otherwise loop a consumer forever.",
"{\n \"pageSize\": 0\n}",
),
(
"Bare/unnamespaced ext key — SPEC §4.5.1 requires every immediate child of ext to be reverse-DNS namespaced.",
"{\n \"ext\": {\n \"bare-key\": {\n \"anything\": \"here\"\n }\n }\n}",
),
];
for (i, (note, raw)) in fixtures.iter().enumerate() {
let value: serde_json::Value = match serde_json::from_str(raw) {
Ok(v) => v,
Err(_) => continue,
};
let serde_ok = serde_json::from_value::<super::Payload>(value.clone()).is_ok();
let schema_ok = super::Payload::validate_value(&value).is_ok();
assert!(
!(serde_ok && schema_ok),
"invalid-example #{} ({:?}) was accepted by both serde and JSON Schema; \
the fixture's stated failure class is no longer caught:\n{}",
i + 1,
note,
raw
);
}
}
}