//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vault/credentials/query`. Version: `0.1`.
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = None;
#[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())
}
}
}
///A body-free projection of a stored credential. Carries no claim content by construction.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct CredentialDescriptor {
///Present iff `lifecycle` is `archived`.
#[serde(
rename = "archivedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub archived_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///Present iff `lifecycle` is `deleted`.
#[serde(
rename = "deletedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub deleted_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///Present iff `lifecycle` is `deleted`. Restorable while now < graceUntil.
#[serde(
rename = "graceUntil",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub grace_until: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///Local handle. Opaque to the consumer; the id `get`, `archive`, `delete` and the rest are keyed on.
pub id: CredentialDescriptorId,
#[serde(
rename = "issuerDid",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub issuer_did: ::std::option::Option<Did>,
///Omitted for active credentials, so an active-only result is unchanged by this member's existence.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub lifecycle: ::std::option::Option<VaultLifecycle>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<CredentialPurpose>,
pub status: CredentialStatus,
///VC `type` tags carried by the credential.
pub types: ::std::vec::Vec<CredentialDescriptorTypesItem>,
#[serde(
rename = "validFrom",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub valid_from: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
#[serde(
rename = "validUntil",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub valid_until: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
}
impl CredentialDescriptor {
pub fn builder() -> builder::CredentialDescriptor {
Default::default()
}
}
///Local handle. Opaque to the consumer; the id `get`, `archive`, `delete` and the rest are keyed on.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CredentialDescriptorId(::std::string::String);
impl ::std::ops::Deref for CredentialDescriptorId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CredentialDescriptorId> for ::std::string::String {
fn from(value: CredentialDescriptorId) -> Self {
value.0
}
}
impl ::std::str::FromStr for CredentialDescriptorId {
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 CredentialDescriptorId {
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 CredentialDescriptorId {
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 CredentialDescriptorId {
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 CredentialDescriptorId {
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())
})
}
}
///`CredentialDescriptorTypesItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CredentialDescriptorTypesItem(::std::string::String);
impl ::std::ops::Deref for CredentialDescriptorTypesItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CredentialDescriptorTypesItem> for ::std::string::String {
fn from(value: CredentialDescriptorTypesItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for CredentialDescriptorTypesItem {
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 CredentialDescriptorTypesItem {
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 CredentialDescriptorTypesItem {
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 CredentialDescriptorTypesItem {
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 CredentialDescriptorTypesItem {
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())
})
}
}
///Semantic classification. `invite`, `membership`, `role`, `endorsement` and `personhood` are defined; a maintainer MAY use another token.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CredentialPurpose(::std::string::String);
impl ::std::ops::Deref for CredentialPurpose {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CredentialPurpose> for ::std::string::String {
fn from(value: CredentialPurpose) -> Self {
value.0
}
}
impl ::std::str::FromStr for CredentialPurpose {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for CredentialPurpose {
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 CredentialPurpose {
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 CredentialPurpose {
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 CredentialPurpose {
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())
})
}
}
///Validity, driven by the credential's own window and by status-list checks. Orthogonal to lifecycle.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum CredentialStatus {
#[serde(rename = "valid")]
Valid,
#[serde(rename = "expired")]
Expired,
#[serde(rename = "revoked")]
Revoked,
#[serde(rename = "unknown")]
Unknown,
}
impl ::std::fmt::Display for CredentialStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Valid => f.write_str("valid"),
Self::Expired => f.write_str("expired"),
Self::Revoked => f.write_str("revoked"),
Self::Unknown => f.write_str("unknown"),
}
}
}
impl ::std::str::FromStr for CredentialStatus {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"valid" => Ok(Self::Valid),
"expired" => Ok(Self::Expired),
"revoked" => Ok(Self::Revoked),
"unknown" => Ok(Self::Unknown),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for CredentialStatus {
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 CredentialStatus {
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 CredentialStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`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())
})
}
}
///A filtered, body-free search over stored credentials. At least one of `type`, `communityDid`, `issuerDid`, `purpose` or `status` MUST be present — see the specification; `includeArchived` and `includeDeleted` are modifiers and do not satisfy that requirement.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Match credentials held for this community or context DID.
#[serde(
rename = "communityDid",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub community_did: ::std::option::Option<Did>,
///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>,
///Modifier, not a filter: also return archived credentials matching the other constraints. Absent means false.
#[serde(
rename = "includeArchived",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub include_archived: ::std::option::Option<bool>,
///Modifier, not a filter: also return soft-deleted tombstones matching the other constraints. Absent means false.
#[serde(
rename = "includeDeleted",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub include_deleted: ::std::option::Option<bool>,
///Match credentials issued by this DID.
#[serde(
rename = "issuerDid",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub issuer_did: ::std::option::Option<Did>,
///Match the maintainer's semantic classification of the credential.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<CredentialPurpose>,
///Match the validity dimension.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<CredentialStatus>,
///Narrow the other constraints to credentials whose subject — the DID a presentation of the credential is made as — is this DID. Narrows only: it does not satisfy the at-least-one-filter requirement on its own.
#[serde(
rename = "subjectDid",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub subject_did: ::std::option::Option<Did>,
///Match credentials carrying this VC `type` tag.
#[serde(
rename = "type",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub type_: ::std::option::Option<PayloadType>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
community_did: Default::default(),
ext: Default::default(),
include_archived: Default::default(),
include_deleted: Default::default(),
issuer_did: Default::default(),
purpose: Default::default(),
status: Default::default(),
subject_did: Default::default(),
type_: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Match credentials carrying this VC `type` tag.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadType(::std::string::String);
impl ::std::ops::Deref for PayloadType {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadType> for ::std::string::String {
fn from(value: PayloadType) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadType {
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 PayloadType {
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 PayloadType {
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 PayloadType {
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 PayloadType {
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]
pub struct Response {
///Matching descriptors. Empty when nothing matched — a successful answer, not an error.
pub credentials: ::std::vec::Vec<CredentialDescriptor>,
///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>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Archival state, chosen through this family. Orthogonal to validity.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum VaultLifecycle {
#[serde(rename = "active")]
Active,
#[serde(rename = "archived")]
Archived,
#[serde(rename = "deleted")]
Deleted,
}
impl ::std::fmt::Display for VaultLifecycle {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Active => f.write_str("active"),
Self::Archived => f.write_str("archived"),
Self::Deleted => f.write_str("deleted"),
}
}
}
impl ::std::str::FromStr for VaultLifecycle {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"active" => Ok(Self::Active),
"archived" => Ok(Self::Archived),
"deleted" => Ok(Self::Deleted),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for VaultLifecycle {
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 VaultLifecycle {
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 VaultLifecycle {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct CredentialDescriptor {
archived_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
deleted_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
grace_until: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
id: ::std::result::Result<super::CredentialDescriptorId, ::std::string::String>,
issuer_did: ::std::result::Result<::std::option::Option<super::Did>, ::std::string::String>,
lifecycle: ::std::result::Result<
::std::option::Option<super::VaultLifecycle>,
::std::string::String,
>,
purpose: ::std::result::Result<
::std::option::Option<super::CredentialPurpose>,
::std::string::String,
>,
status: ::std::result::Result<super::CredentialStatus, ::std::string::String>,
types: ::std::result::Result<
::std::vec::Vec<super::CredentialDescriptorTypesItem>,
::std::string::String,
>,
valid_from: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
valid_until: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
}
impl ::std::default::Default for CredentialDescriptor {
fn default() -> Self {
Self {
archived_at: Ok(Default::default()),
deleted_at: Ok(Default::default()),
grace_until: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
issuer_did: Ok(Default::default()),
lifecycle: Ok(Default::default()),
purpose: Ok(Default::default()),
status: Err("no value supplied for status".to_string()),
types: Err("no value supplied for types".to_string()),
valid_from: Ok(Default::default()),
valid_until: Ok(Default::default()),
}
}
}
impl CredentialDescriptor {
pub fn archived_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.archived_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for archived_at: {e}"));
self
}
pub fn deleted_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.deleted_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for deleted_at: {e}"));
self
}
pub fn grace_until<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.grace_until = value
.try_into()
.map_err(|e| format!("error converting supplied value for grace_until: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CredentialDescriptorId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn issuer_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Did>>,
T::Error: ::std::fmt::Display,
{
self.issuer_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for issuer_did: {e}"));
self
}
pub fn lifecycle<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::VaultLifecycle>>,
T::Error: ::std::fmt::Display,
{
self.lifecycle = value
.try_into()
.map_err(|e| format!("error converting supplied value for lifecycle: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::CredentialPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| format!("error converting supplied value for purpose: {e}"));
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CredentialStatus>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn types<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::CredentialDescriptorTypesItem>>,
T::Error: ::std::fmt::Display,
{
self.types = value
.try_into()
.map_err(|e| format!("error converting supplied value for types: {e}"));
self
}
pub fn valid_from<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.valid_from = value
.try_into()
.map_err(|e| format!("error converting supplied value for valid_from: {e}"));
self
}
pub fn valid_until<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.valid_until = value
.try_into()
.map_err(|e| format!("error converting supplied value for valid_until: {e}"));
self
}
}
impl ::std::convert::TryFrom<CredentialDescriptor> for super::CredentialDescriptor {
type Error = super::error::ConversionError;
fn try_from(
value: CredentialDescriptor,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
archived_at: value.archived_at?,
deleted_at: value.deleted_at?,
grace_until: value.grace_until?,
id: value.id?,
issuer_did: value.issuer_did?,
lifecycle: value.lifecycle?,
purpose: value.purpose?,
status: value.status?,
types: value.types?,
valid_from: value.valid_from?,
valid_until: value.valid_until?,
})
}
}
impl ::std::convert::From<super::CredentialDescriptor> for CredentialDescriptor {
fn from(value: super::CredentialDescriptor) -> Self {
Self {
archived_at: Ok(value.archived_at),
deleted_at: Ok(value.deleted_at),
grace_until: Ok(value.grace_until),
id: Ok(value.id),
issuer_did: Ok(value.issuer_did),
lifecycle: Ok(value.lifecycle),
purpose: Ok(value.purpose),
status: Ok(value.status),
types: Ok(value.types),
valid_from: Ok(value.valid_from),
valid_until: Ok(value.valid_until),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
community_did:
::std::result::Result<::std::option::Option<super::Did>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
include_archived: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
include_deleted: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
issuer_did: ::std::result::Result<::std::option::Option<super::Did>, ::std::string::String>,
purpose: ::std::result::Result<
::std::option::Option<super::CredentialPurpose>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::CredentialStatus>,
::std::string::String,
>,
subject_did:
::std::result::Result<::std::option::Option<super::Did>, ::std::string::String>,
type_:
::std::result::Result<::std::option::Option<super::PayloadType>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
community_did: Ok(Default::default()),
ext: Ok(Default::default()),
include_archived: Ok(Default::default()),
include_deleted: Ok(Default::default()),
issuer_did: Ok(Default::default()),
purpose: Ok(Default::default()),
status: Ok(Default::default()),
subject_did: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Payload {
pub fn community_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Did>>,
T::Error: ::std::fmt::Display,
{
self.community_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for community_did: {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 include_archived<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.include_archived = value
.try_into()
.map_err(|e| format!("error converting supplied value for include_archived: {e}"));
self
}
pub fn include_deleted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.include_deleted = value
.try_into()
.map_err(|e| format!("error converting supplied value for include_deleted: {e}"));
self
}
pub fn issuer_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Did>>,
T::Error: ::std::fmt::Display,
{
self.issuer_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for issuer_did: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::CredentialPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| format!("error converting supplied value for purpose: {e}"));
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::CredentialStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn subject_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Did>>,
T::Error: ::std::fmt::Display,
{
self.subject_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for subject_did: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadType>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {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 {
community_did: value.community_did?,
ext: value.ext?,
include_archived: value.include_archived?,
include_deleted: value.include_deleted?,
issuer_did: value.issuer_did?,
purpose: value.purpose?,
status: value.status?,
subject_did: value.subject_did?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
community_did: Ok(value.community_did),
ext: Ok(value.ext),
include_archived: Ok(value.include_archived),
include_deleted: Ok(value.include_deleted),
issuer_did: Ok(value.issuer_did),
purpose: Ok(value.purpose),
status: Ok(value.status),
subject_did: Ok(value.subject_did),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
credentials: ::std::result::Result<
::std::vec::Vec<super::CredentialDescriptor>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
credentials: Err("no value supplied for credentials".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Response {
pub fn credentials<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::CredentialDescriptor>>,
T::Error: ::std::fmt::Display,
{
self.credentials = value
.try_into()
.map_err(|e| format!("error converting supplied value for credentials: {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
}
}
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?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
credentials: Ok(value.credentials),
ext: Ok(value.ext),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vault/credentials/query/0.1";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"CredentialDescriptor\":{\"additionalProperties\":false,\"description\":\"A body-free projection of a stored credential. Carries no claim content by construction.\",\"properties\":{\"archivedAt\":{\"description\":\"Present iff `lifecycle` is `archived`.\",\"format\":\"date-time\",\"type\":\"string\"},\"deletedAt\":{\"description\":\"Present iff `lifecycle` is `deleted`.\",\"format\":\"date-time\",\"type\":\"string\"},\"graceUntil\":{\"description\":\"Present iff `lifecycle` is `deleted`. Restorable while now < graceUntil.\",\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"description\":\"Local handle. Opaque to the consumer; the id `get`, `archive`, `delete` and the rest are keyed on.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"issuerDid\":{\"$ref\":\"#/$defs/Did\"},\"lifecycle\":{\"$ref\":\"#/$defs/VaultLifecycle\",\"description\":\"Omitted for active credentials, so an active-only result is unchanged by this member's existence.\"},\"purpose\":{\"$ref\":\"#/$defs/CredentialPurpose\"},\"status\":{\"$ref\":\"#/$defs/CredentialStatus\"},\"types\":{\"description\":\"VC `type` tags carried by the credential.\",\"items\":{\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"type\":\"array\"},\"validFrom\":{\"format\":\"date-time\",\"type\":\"string\"},\"validUntil\":{\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"id\",\"types\",\"status\"],\"title\":\"Credential descriptor\",\"type\":\"object\"},\"CredentialPurpose\":{\"description\":\"Semantic classification. `invite`, `membership`, `role`, `endorsement` and `personhood` are defined; a maintainer MAY use another token.\",\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"CredentialStatus\":{\"description\":\"Validity, driven by the credential's own window and by status-list checks. Orthogonal to lifecycle.\",\"enum\":[\"valid\",\"expired\",\"revoked\",\"unknown\"],\"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\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"credentials\":{\"description\":\"Matching descriptors. Empty when nothing matched — a successful answer, not an error.\",\"items\":{\"$ref\":\"#/$defs/CredentialDescriptor\"},\"type\":\"array\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"}},\"required\":[\"credentials\"],\"title\":\"Vault Credentials Query — response payload\",\"type\":\"object\"},\"VaultLifecycle\":{\"description\":\"Archival state, chosen through this family. Orthogonal to validity.\",\"enum\":[\"active\",\"archived\",\"deleted\"],\"type\":\"string\"}},\"$id\":\"https://trusttasks.org/spec/vault/credentials/query/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"A filtered, body-free search over stored credentials. At least one of `type`, `communityDid`, `issuerDid`, `purpose` or `status` MUST be present — see the specification; `includeArchived` and `includeDeleted` are modifiers and do not satisfy that requirement.\",\"properties\":{\"communityDid\":{\"$ref\":\"#/$defs/Did\",\"description\":\"Match credentials held for this community or context DID.\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"includeArchived\":{\"description\":\"Modifier, not a filter: also return archived credentials matching the other constraints. Absent means false.\",\"type\":\"boolean\"},\"includeDeleted\":{\"description\":\"Modifier, not a filter: also return soft-deleted tombstones matching the other constraints. Absent means false.\",\"type\":\"boolean\"},\"issuerDid\":{\"$ref\":\"#/$defs/Did\",\"description\":\"Match credentials issued by this DID.\"},\"purpose\":{\"$ref\":\"#/$defs/CredentialPurpose\",\"description\":\"Match the maintainer's semantic classification of the credential.\"},\"status\":{\"$ref\":\"#/$defs/CredentialStatus\",\"description\":\"Match the validity dimension.\"},\"subjectDid\":{\"$ref\":\"#/$defs/Did\",\"description\":\"Narrow the other constraints to credentials whose subject — the DID a presentation of the credential is made as — is this DID. Narrows only: it does not satisfy the at-least-one-filter requirement on its own.\"},\"type\":{\"description\":\"Match credentials carrying this VC `type` tag.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"}},\"title\":\"Vault Credentials — Query\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vault/credentials/query/0.1#response";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"CredentialDescriptor\":{\"additionalProperties\":false,\"description\":\"A body-free projection of a stored credential. Carries no claim content by construction.\",\"properties\":{\"archivedAt\":{\"description\":\"Present iff `lifecycle` is `archived`.\",\"format\":\"date-time\",\"type\":\"string\"},\"deletedAt\":{\"description\":\"Present iff `lifecycle` is `deleted`.\",\"format\":\"date-time\",\"type\":\"string\"},\"graceUntil\":{\"description\":\"Present iff `lifecycle` is `deleted`. Restorable while now < graceUntil.\",\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"description\":\"Local handle. Opaque to the consumer; the id `get`, `archive`, `delete` and the rest are keyed on.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"issuerDid\":{\"$ref\":\"#/$defs/Did\"},\"lifecycle\":{\"$ref\":\"#/$defs/VaultLifecycle\",\"description\":\"Omitted for active credentials, so an active-only result is unchanged by this member's existence.\"},\"purpose\":{\"$ref\":\"#/$defs/CredentialPurpose\"},\"status\":{\"$ref\":\"#/$defs/CredentialStatus\"},\"types\":{\"description\":\"VC `type` tags carried by the credential.\",\"items\":{\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"type\":\"array\"},\"validFrom\":{\"format\":\"date-time\",\"type\":\"string\"},\"validUntil\":{\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"id\",\"types\",\"status\"],\"title\":\"Credential descriptor\",\"type\":\"object\"},\"CredentialPurpose\":{\"description\":\"Semantic classification. `invite`, `membership`, `role`, `endorsement` and `personhood` are defined; a maintainer MAY use another token.\",\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"CredentialStatus\":{\"description\":\"Validity, driven by the credential's own window and by status-list checks. Orthogonal to lifecycle.\",\"enum\":[\"valid\",\"expired\",\"revoked\",\"unknown\"],\"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\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"credentials\":{\"description\":\"Matching descriptors. Empty when nothing matched — a successful answer, not an error.\",\"items\":{\"$ref\":\"#/$defs/CredentialDescriptor\"},\"type\":\"array\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"}},\"required\":[\"credentials\"],\"title\":\"Vault Credentials Query — response payload\",\"type\":\"object\"},\"VaultLifecycle\":{\"description\":\"Archival state, chosen through this family. Orthogonal to validity.\",\"enum\":[\"active\",\"archived\",\"deleted\"],\"type\":\"string\"}},\"$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::FILTER_REQUIRED];
/// 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 {
/// `vault/credentials/query:filterRequired`
///
/// The filter carried no constraint the maintainer can scan on. An unconstrained query would enumerate the consumer's whole vault, so it is refused rather than answered. `includeArchived` and `includeDeleted` are modifiers and do not satisfy this requirement on their own.
///
/// Declared `retryable: false`.
pub const FILTER_REQUIRED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vault/credentials/query:filterRequired",
retryable: false,
details_schema: ::core::option::Option::None,
};
}