//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/credentials/list`. Version: `0.1`.
#![allow(deprecated)]
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = Some("superseded by vta/credentials/list/0.2");
#[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.
///
#[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`
///
#[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.
///
#[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`
///
#[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.
///
#[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.
///
#[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.
///
#[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.
///
#[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.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by vta/credentials/list/0.2")]
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`.
///
#[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.
///
#[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`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by vta/credentials/list/0.2")]
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.
///
#[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(
"{\"$defs\":{\"CredentialId\":{\"$anchor\":\"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.\",\"minLength\":1,\"title\":\"CredentialId\",\"type\":\"string\"},\"Did\":{\"maxLength\":2048,\"pattern\":\"^did:[a-z0-9]+:.+$\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"IssuedCredentialStatus\":{\"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.\",\"enum\":[\"active\",\"expired\",\"revoked\"],\"type\":\"string\"},\"IssuedCredentialSummary\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"credentialId\":{\"$ref\":\"#/$defs/CredentialId\",\"description\":\"The id `vta/credentials/revoke` is keyed on.\"},\"credentialType\":{\"description\":\"The type tag beyond `VerifiableCredential`, when the credential carries one.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"expiresAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"holder\":{\"$ref\":\"#/$defs/Did\",\"description\":\"Who the credential was issued to.\"},\"issuedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"revocationReason\":{\"description\":\"Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.\",\"maxLength\":1024,\"type\":\"string\"},\"revokedAt\":{\"description\":\"Present iff `status` is `revoked`.\",\"format\":\"date-time\",\"type\":\"string\"},\"status\":{\"$ref\":\"#/$defs/IssuedCredentialStatus\"}},\"required\":[\"credentialId\",\"holder\",\"issuedAt\",\"expiresAt\",\"status\"],\"title\":\"IssuedCredentialSummary\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"credentials\":{\"description\":\"One summary per matching credential. Empty when nothing matched — a successful answer, not an error.\",\"items\":{\"$ref\":\"#/$defs/IssuedCredentialSummary\"},\"type\":\"array\"},\"cursor\":{\"description\":\"Pass to the next request to continue. Absent when the page is the last.\",\"maxLength\":4096,\"minLength\":1,\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"truncated\":{\"description\":\"The agent stopped early. A consumer must not read a truncated page as a complete account of what was issued.\",\"type\":\"boolean\"}},\"required\":[\"credentials\",\"truncated\"],\"title\":\"VTA Credentials List — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vta/credentials/list/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Enumerate the credentials an agent has issued, as metadata. Every filter is optional and those present are AND-combined.\",\"properties\":{\"credentialType\":{\"description\":\"Only credentials carrying this type tag beyond `VerifiableCredential`.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"cursor\":{\"description\":\"Continue a previous page. Opaque — consumers must not construct or parse one.\",\"maxLength\":4096,\"minLength\":1,\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"holder\":{\"$ref\":\"#/$defs/Did\",\"description\":\"Only credentials issued to this DID.\"},\"pageSize\":{\"description\":\"Maximum records to return. The agent MAY return fewer and caps this value.\",\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"},\"status\":{\"$ref\":\"#/$defs/IssuedCredentialStatus\",\"description\":\"Only credentials in this state. Derived by the agent at read time, never stored.\"}},\"title\":\"VTA Credentials — List\",\"type\":\"object\"}\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(
"{\"$defs\":{\"CredentialId\":{\"$anchor\":\"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.\",\"minLength\":1,\"title\":\"CredentialId\",\"type\":\"string\"},\"Did\":{\"maxLength\":2048,\"pattern\":\"^did:[a-z0-9]+:.+$\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"IssuedCredentialStatus\":{\"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.\",\"enum\":[\"active\",\"expired\",\"revoked\"],\"type\":\"string\"},\"IssuedCredentialSummary\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"credentialId\":{\"$ref\":\"#/$defs/CredentialId\",\"description\":\"The id `vta/credentials/revoke` is keyed on.\"},\"credentialType\":{\"description\":\"The type tag beyond `VerifiableCredential`, when the credential carries one.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"expiresAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"holder\":{\"$ref\":\"#/$defs/Did\",\"description\":\"Who the credential was issued to.\"},\"issuedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"revocationReason\":{\"description\":\"Free text recorded at revocation. Disclosed to every caller entitled to this list — see Security & Privacy.\",\"maxLength\":1024,\"type\":\"string\"},\"revokedAt\":{\"description\":\"Present iff `status` is `revoked`.\",\"format\":\"date-time\",\"type\":\"string\"},\"status\":{\"$ref\":\"#/$defs/IssuedCredentialStatus\"}},\"required\":[\"credentialId\",\"holder\",\"issuedAt\",\"expiresAt\",\"status\"],\"title\":\"IssuedCredentialSummary\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"credentials\":{\"description\":\"One summary per matching credential. Empty when nothing matched — a successful answer, not an error.\",\"items\":{\"$ref\":\"#/$defs/IssuedCredentialSummary\"},\"type\":\"array\"},\"cursor\":{\"description\":\"Pass to the next request to continue. Absent when the page is the last.\",\"maxLength\":4096,\"minLength\":1,\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"truncated\":{\"description\":\"The agent stopped early. A consumer must not read a truncated page as a complete account of what was issued.\",\"type\":\"boolean\"}},\"required\":[\"credentials\",\"truncated\"],\"title\":\"VTA Credentials List — response payload\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// 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::CURSOR_INVALID];
/// 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 {
/// `vta/credentials/list:cursorInvalid`
///
/// The supplied `cursor` cannot be honoured — expired, malformed, or issued against agent state no longer recognised. Consumers SHOULD retry from the first page without a cursor.
///
/// Declared `retryable: true`.
pub const CURSOR_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/credentials/list:cursorInvalid",
retryable: true,
details_schema: ::core::option::Option::None,
};
}