//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vtc/join-requests/status`. 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())
}
}
}
///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())
})
}
}
///`Payload`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The request to poll. Optional: an applicant whose first reply was lost never received an id, and the id-less poll — resolved from the authenticated applicant's own DID — is the only form available to them. Supply it when you have it; a consumer that has it MUST prefer it over inferring the request from the caller.
#[serde(
rename = "requestId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub request_id: ::std::option::Option<PayloadRequestId>,
///Ask the community to deliver again the membership credential and role credential it already issued for this request, when the request is `approved` and they have not arrived. Set it only after a response of `approved` with `credentialsDelivered: false` and a reasonable wait; the community rate-limits it and answers in `credentialResend`. The community never issues new credentials in response.
#[serde(
rename = "resendCredentials",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub resend_credentials: ::std::option::Option<bool>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Default::default(),
request_id: Default::default(),
resend_credentials: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The request to poll. Optional: an applicant whose first reply was lost never received an id, and the id-less poll — resolved from the authenticated applicant's own DID — is the only form available to them. Supply it when you have it; a consumer that has it MUST prefer it over inferring the request from the caller.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadRequestId(::std::string::String);
impl ::std::ops::Deref for PayloadRequestId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadRequestId> for ::std::string::String {
fn from(value: PayloadRequestId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadRequestId {
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 PayloadRequestId {
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 PayloadRequestId {
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 PayloadRequestId {
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 PayloadRequestId {
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 {
///Stable refusal code, safe to branch on. Present only when `status` is `rejected`.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///The community's answer to `resendCredentials`. `queued`: a re-delivery of the already-issued credentials is queued. `notNeeded`: delivery is already acknowledged. `rateLimited`: a re-delivery was honoured too recently; see `retryAfter`. Present only when `resendCredentials` was set and `status` is `approved`; absent then means the community does not support re-delivery.
#[serde(
rename = "credentialResend",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub credential_resend: ::std::option::Option<ResponseCredentialResend>,
///Whether the community holds the applicant's acknowledgement that the membership credential arrived. Present only when `status` is `approved`.
#[serde(
rename = "credentialsDelivered",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub credentials_delivered: ::std::option::Option<bool>,
///When the refusal was decided — not when this poll was produced. Present only when `status` is `rejected`.
#[serde(
rename = "decidedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub decided_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///When deferred, what the applicant must supply next.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub needs: ::std::vec::Vec<::std::string::String>,
///When more evidence is needed, the presentation-definition to satisfy (opaque here).
#[serde(
rename = "presentationDefinition",
default,
skip_serializing_if = "::serde_json::Map::is_empty"
)]
pub presentation_definition: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Elaboration in prose, when the decider gave one. Present only when `status` is `rejected`.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub reason: ::std::option::Option<ResponseReason>,
#[serde(rename = "requestId")]
pub request_id: ResponseRequestId,
///The earliest time the community will honour another `resendCredentials`. Present only when `credentialResend` is `rateLimited`.
#[serde(
rename = "retryAfter",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub retry_after: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
pub status: ResponseStatus,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///The community's answer to `resendCredentials`. `queued`: a re-delivery of the already-issued credentials is queued. `notNeeded`: delivery is already acknowledged. `rateLimited`: a re-delivery was honoured too recently; see `retryAfter`. Present only when `resendCredentials` was set and `status` is `approved`; absent then means the community does not support re-delivery.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseCredentialResend {
#[serde(rename = "queued")]
Queued,
#[serde(rename = "notNeeded")]
NotNeeded,
#[serde(rename = "rateLimited")]
RateLimited,
}
impl ::std::fmt::Display for ResponseCredentialResend {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Queued => f.write_str("queued"),
Self::NotNeeded => f.write_str("notNeeded"),
Self::RateLimited => f.write_str("rateLimited"),
}
}
}
impl ::std::str::FromStr for ResponseCredentialResend {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"queued" => Ok(Self::Queued),
"notNeeded" => Ok(Self::NotNeeded),
"rateLimited" => Ok(Self::RateLimited),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseCredentialResend {
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 ResponseCredentialResend {
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 ResponseCredentialResend {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Elaboration in prose, when the decider gave one. Present only when `status` is `rejected`.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseReason(::std::string::String);
impl ::std::ops::Deref for ResponseReason {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseReason> for ::std::string::String {
fn from(value: ResponseReason) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseReason {
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 ResponseReason {
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 ResponseReason {
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 ResponseReason {
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 ResponseReason {
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())
})
}
}
///`ResponseRequestId`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseRequestId(::std::string::String);
impl ::std::ops::Deref for ResponseRequestId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseRequestId> for ::std::string::String {
fn from(value: ResponseRequestId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseRequestId {
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 ResponseRequestId {
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 ResponseRequestId {
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 ResponseRequestId {
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 ResponseRequestId {
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())
})
}
}
///`ResponseStatus`
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseStatus {
#[serde(rename = "pending")]
Pending,
#[serde(rename = "deferred")]
Deferred,
#[serde(rename = "approved")]
Approved,
#[serde(rename = "rejected")]
Rejected,
#[serde(rename = "withdrawn")]
Withdrawn,
}
impl ::std::fmt::Display for ResponseStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Pending => f.write_str("pending"),
Self::Deferred => f.write_str("deferred"),
Self::Approved => f.write_str("approved"),
Self::Rejected => f.write_str("rejected"),
Self::Withdrawn => f.write_str("withdrawn"),
}
}
}
impl ::std::str::FromStr for ResponseStatus {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"pending" => Ok(Self::Pending),
"deferred" => Ok(Self::Deferred),
"approved" => Ok(Self::Approved),
"rejected" => Ok(Self::Rejected),
"withdrawn" => Ok(Self::Withdrawn),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseStatus {
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 ResponseStatus {
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 ResponseStatus {
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 Payload {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
request_id: ::std::result::Result<
::std::option::Option<super::PayloadRequestId>,
::std::string::String,
>,
resend_credentials:
::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
request_id: Ok(Default::default()),
resend_credentials: Ok(Default::default()),
}
}
}
impl Payload {
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 request_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadRequestId>>,
T::Error: ::std::fmt::Display,
{
self.request_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for request_id: {e}"));
self
}
pub fn resend_credentials<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.resend_credentials = value.try_into().map_err(|e| {
format!("error converting supplied value for resend_credentials: {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 {
ext: value.ext?,
request_id: value.request_id?,
resend_credentials: value.resend_credentials?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ext: Ok(value.ext),
request_id: Ok(value.request_id),
resend_credentials: Ok(value.resend_credentials),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
credential_resend: ::std::result::Result<
::std::option::Option<super::ResponseCredentialResend>,
::std::string::String,
>,
credentials_delivered:
::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
decided_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
needs: ::std::result::Result<::std::vec::Vec<::std::string::String>, ::std::string::String>,
presentation_definition: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
reason: ::std::result::Result<
::std::option::Option<super::ResponseReason>,
::std::string::String,
>,
request_id: ::std::result::Result<super::ResponseRequestId, ::std::string::String>,
retry_after: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
status: ::std::result::Result<super::ResponseStatus, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
code: Ok(Default::default()),
credential_resend: Ok(Default::default()),
credentials_delivered: Ok(Default::default()),
decided_at: Ok(Default::default()),
ext: Ok(Default::default()),
needs: Ok(Default::default()),
presentation_definition: Ok(Default::default()),
reason: Ok(Default::default()),
request_id: Err("no value supplied for request_id".to_string()),
retry_after: Ok(Default::default()),
status: Err("no value supplied for status".to_string()),
}
}
}
impl Response {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn credential_resend<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCredentialResend>>,
T::Error: ::std::fmt::Display,
{
self.credential_resend = value
.try_into()
.map_err(|e| format!("error converting supplied value for credential_resend: {e}"));
self
}
pub fn credentials_delivered<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.credentials_delivered = value.try_into().map_err(|e| {
format!("error converting supplied value for credentials_delivered: {e}")
});
self
}
pub fn decided_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.decided_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for decided_at: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn needs<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.needs = value
.try_into()
.map_err(|e| format!("error converting supplied value for needs: {e}"));
self
}
pub fn presentation_definition<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.presentation_definition = value.try_into().map_err(|e| {
format!("error converting supplied value for presentation_definition: {e}")
});
self
}
pub fn reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseReason>>,
T::Error: ::std::fmt::Display,
{
self.reason = value
.try_into()
.map_err(|e| format!("error converting supplied value for reason: {e}"));
self
}
pub fn request_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseRequestId>,
T::Error: ::std::fmt::Display,
{
self.request_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for request_id: {e}"));
self
}
pub fn retry_after<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.retry_after = value
.try_into()
.map_err(|e| format!("error converting supplied value for retry_after: {e}"));
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseStatus>,
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<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
credential_resend: value.credential_resend?,
credentials_delivered: value.credentials_delivered?,
decided_at: value.decided_at?,
ext: value.ext?,
needs: value.needs?,
presentation_definition: value.presentation_definition?,
reason: value.reason?,
request_id: value.request_id?,
retry_after: value.retry_after?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
code: Ok(value.code),
credential_resend: Ok(value.credential_resend),
credentials_delivered: Ok(value.credentials_delivered),
decided_at: Ok(value.decided_at),
ext: Ok(value.ext),
needs: Ok(value.needs),
presentation_definition: Ok(value.presentation_definition),
reason: Ok(value.reason),
request_id: Ok(value.request_id),
retry_after: Ok(value.retry_after),
status: Ok(value.status),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vtc/join-requests/status/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"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\":{\"code\":{\"description\":\"Stable refusal code, safe to branch on. Present only when `status` is `rejected`.\",\"type\":\"string\"},\"credentialResend\":{\"description\":\"The community's answer to `resendCredentials`. `queued`: a re-delivery of the already-issued credentials is queued. `notNeeded`: delivery is already acknowledged. `rateLimited`: a re-delivery was honoured too recently; see `retryAfter`. Present only when `resendCredentials` was set and `status` is `approved`; absent then means the community does not support re-delivery.\",\"enum\":[\"queued\",\"notNeeded\",\"rateLimited\"],\"type\":\"string\"},\"credentialsDelivered\":{\"description\":\"Whether the community holds the applicant's acknowledgement that the membership credential arrived. Present only when `status` is `approved`.\",\"type\":\"boolean\"},\"decidedAt\":{\"description\":\"When the refusal was decided — not when this poll was produced. Present only when `status` is `rejected`.\",\"format\":\"date-time\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"needs\":{\"description\":\"When deferred, what the applicant must supply next.\",\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"presentationDefinition\":{\"description\":\"When more evidence is needed, the presentation-definition to satisfy (opaque here).\",\"type\":\"object\"},\"reason\":{\"description\":\"Elaboration in prose, when the decider gave one. Present only when `status` is `rejected`.\",\"maxLength\":1024,\"type\":[\"string\",\"null\"]},\"requestId\":{\"minLength\":1,\"type\":\"string\"},\"retryAfter\":{\"description\":\"The earliest time the community will honour another `resendCredentials`. Present only when `credentialResend` is `rateLimited`.\",\"format\":\"date-time\",\"type\":\"string\"},\"status\":{\"enum\":[\"pending\",\"deferred\",\"approved\",\"rejected\",\"withdrawn\"],\"type\":\"string\"}},\"required\":[\"requestId\",\"status\"],\"title\":\"VTC Join-Requests Status — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vtc/join-requests/status/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"requestId\":{\"description\":\"The request to poll. Optional: an applicant whose first reply was lost never received an id, and the id-less poll — resolved from the authenticated applicant's own DID — is the only form available to them. Supply it when you have it; a consumer that has it MUST prefer it over inferring the request from the caller.\",\"minLength\":1,\"type\":\"string\"},\"resendCredentials\":{\"description\":\"Ask the community to deliver again the membership credential and role credential it already issued for this request, when the request is `approved` and they have not arrived. Set it only after a response of `approved` with `credentialsDelivered: false` and a reasonable wait; the community rate-limits it and answers in `credentialResend`. The community never issues new credentials in response.\",\"type\":\"boolean\"}},\"title\":\"VTC Join-Requests Status — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vtc/join-requests/status/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"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\":{\"code\":{\"description\":\"Stable refusal code, safe to branch on. Present only when `status` is `rejected`.\",\"type\":\"string\"},\"credentialResend\":{\"description\":\"The community's answer to `resendCredentials`. `queued`: a re-delivery of the already-issued credentials is queued. `notNeeded`: delivery is already acknowledged. `rateLimited`: a re-delivery was honoured too recently; see `retryAfter`. Present only when `resendCredentials` was set and `status` is `approved`; absent then means the community does not support re-delivery.\",\"enum\":[\"queued\",\"notNeeded\",\"rateLimited\"],\"type\":\"string\"},\"credentialsDelivered\":{\"description\":\"Whether the community holds the applicant's acknowledgement that the membership credential arrived. Present only when `status` is `approved`.\",\"type\":\"boolean\"},\"decidedAt\":{\"description\":\"When the refusal was decided — not when this poll was produced. Present only when `status` is `rejected`.\",\"format\":\"date-time\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"needs\":{\"description\":\"When deferred, what the applicant must supply next.\",\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"presentationDefinition\":{\"description\":\"When more evidence is needed, the presentation-definition to satisfy (opaque here).\",\"type\":\"object\"},\"reason\":{\"description\":\"Elaboration in prose, when the decider gave one. Present only when `status` is `rejected`.\",\"maxLength\":1024,\"type\":[\"string\",\"null\"]},\"requestId\":{\"minLength\":1,\"type\":\"string\"},\"retryAfter\":{\"description\":\"The earliest time the community will honour another `resendCredentials`. Present only when `credentialResend` is `rateLimited`.\",\"format\":\"date-time\",\"type\":\"string\"},\"status\":{\"enum\":[\"pending\",\"deferred\",\"approved\",\"rejected\",\"withdrawn\"],\"type\":\"string\"}},\"required\":[\"requestId\",\"status\"],\"title\":\"VTC Join-Requests Status — 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::NOT_FOUND];
/// 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 {
/// `vtc/join-requests/status:notFound`
///
/// No join request with the supplied requestId exists, or it does not belong to the proof signer.
///
/// Declared `retryable: false`.
pub const NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/join-requests/status:notFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
}