//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/services/report`. Version: `0.2`.
/// 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())
})
}
}
///`MediatorStats`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct MediatorStats {
///The first arrival through it in the window.
#[serde(rename = "firstSeenAt")]
pub first_seen_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Messages that arrived through it in the window, over every mediated transport.
#[serde(rename = "inboundCount")]
pub inbound_count: u64,
///The last arrival through it in the window.
#[serde(rename = "lastSeenAt")]
pub last_seen_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The mediator the traffic arrived through.
#[serde(rename = "mediatorDid")]
pub mediator_did: MediatorStatsMediatorDid,
}
impl MediatorStats {
pub fn builder() -> builder::MediatorStats {
Default::default()
}
}
///The mediator the traffic arrived through.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct MediatorStatsMediatorDid(::std::string::String);
impl ::std::ops::Deref for MediatorStatsMediatorDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<MediatorStatsMediatorDid> for ::std::string::String {
fn from(value: MediatorStatsMediatorDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for MediatorStatsMediatorDid {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1000usize {
return Err("longer than 1000 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 MediatorStatsMediatorDid {
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 MediatorStatsMediatorDid {
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 MediatorStatsMediatorDid {
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 MediatorStatsMediatorDid {
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())
})
}
}
///Asks an agent for its per-mediator inbound counts and each sender's last-seen mediator over a time window. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///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>,
///Lower bound, RFC 3339. Absent means as far back as the agent's telemetry goes.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub since: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///Upper bound, RFC 3339. Absent means now.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub until: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Default::default(),
since: Default::default(),
until: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///`Response`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///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>,
///One entry per mediator that carried inbound traffic in the window.
pub mediators: ::std::vec::Vec<MediatorStats>,
///One entry per sender that reached the agent in the window.
pub senders: ::std::vec::Vec<SenderLastSeen>,
///The lower bound applied, when the request gave one.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub since: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///The upper bound applied — now, when the request gave none.
pub until: ::chrono::DateTime<::chrono::offset::Utc>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`SenderLastSeen`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct SenderLastSeen {
///When that message arrived.
#[serde(rename = "lastSeenAt")]
pub last_seen_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The mediator its most recent message arrived through.
#[serde(rename = "lastSeenMediator")]
pub last_seen_mediator: SenderLastSeenLastSeenMediator,
///The mediated transport the sender's most recent message arrived by. Absent when the agent's telemetry did not record it.
#[serde(
rename = "lastSeenTransport",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub last_seen_transport: ::std::option::Option<SenderLastSeenLastSeenTransport>,
///A sender that reached the agent in the window.
#[serde(rename = "senderDid")]
pub sender_did: SenderLastSeenSenderDid,
}
impl SenderLastSeen {
pub fn builder() -> builder::SenderLastSeen {
Default::default()
}
}
///The mediator its most recent message arrived through.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SenderLastSeenLastSeenMediator(::std::string::String);
impl ::std::ops::Deref for SenderLastSeenLastSeenMediator {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SenderLastSeenLastSeenMediator> for ::std::string::String {
fn from(value: SenderLastSeenLastSeenMediator) -> Self {
value.0
}
}
impl ::std::str::FromStr for SenderLastSeenLastSeenMediator {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1000usize {
return Err("longer than 1000 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 SenderLastSeenLastSeenMediator {
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 SenderLastSeenLastSeenMediator {
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 SenderLastSeenLastSeenMediator {
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 SenderLastSeenLastSeenMediator {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The mediated transport the sender's most recent message arrived by. Absent when the agent's telemetry did not record it.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum SenderLastSeenLastSeenTransport {
#[serde(rename = "didcomm")]
Didcomm,
#[serde(rename = "tsp")]
Tsp,
}
impl ::std::fmt::Display for SenderLastSeenLastSeenTransport {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Didcomm => f.write_str("didcomm"),
Self::Tsp => f.write_str("tsp"),
}
}
}
impl ::std::str::FromStr for SenderLastSeenLastSeenTransport {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"didcomm" => Ok(Self::Didcomm),
"tsp" => Ok(Self::Tsp),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for SenderLastSeenLastSeenTransport {
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 SenderLastSeenLastSeenTransport {
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 SenderLastSeenLastSeenTransport {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A sender that reached the agent in the window.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SenderLastSeenSenderDid(::std::string::String);
impl ::std::ops::Deref for SenderLastSeenSenderDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SenderLastSeenSenderDid> for ::std::string::String {
fn from(value: SenderLastSeenSenderDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for SenderLastSeenSenderDid {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1000usize {
return Err("longer than 1000 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 SenderLastSeenSenderDid {
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 SenderLastSeenSenderDid {
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 SenderLastSeenSenderDid {
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 SenderLastSeenSenderDid {
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 MediatorStats {
first_seen_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
inbound_count: ::std::result::Result<u64, ::std::string::String>,
last_seen_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
mediator_did: ::std::result::Result<super::MediatorStatsMediatorDid, ::std::string::String>,
}
impl ::std::default::Default for MediatorStats {
fn default() -> Self {
Self {
first_seen_at: Err("no value supplied for first_seen_at".to_string()),
inbound_count: Err("no value supplied for inbound_count".to_string()),
last_seen_at: Err("no value supplied for last_seen_at".to_string()),
mediator_did: Err("no value supplied for mediator_did".to_string()),
}
}
}
impl MediatorStats {
pub fn first_seen_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.first_seen_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for first_seen_at: {e}"));
self
}
pub fn inbound_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.inbound_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for inbound_count: {e}"));
self
}
pub fn last_seen_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.last_seen_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for last_seen_at: {e}"));
self
}
pub fn mediator_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MediatorStatsMediatorDid>,
T::Error: ::std::fmt::Display,
{
self.mediator_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for mediator_did: {e}"));
self
}
}
impl ::std::convert::TryFrom<MediatorStats> for super::MediatorStats {
type Error = super::error::ConversionError;
fn try_from(
value: MediatorStats,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
first_seen_at: value.first_seen_at?,
inbound_count: value.inbound_count?,
last_seen_at: value.last_seen_at?,
mediator_did: value.mediator_did?,
})
}
}
impl ::std::convert::From<super::MediatorStats> for MediatorStats {
fn from(value: super::MediatorStats) -> Self {
Self {
first_seen_at: Ok(value.first_seen_at),
inbound_count: Ok(value.inbound_count),
last_seen_at: Ok(value.last_seen_at),
mediator_did: Ok(value.mediator_did),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
since: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
until: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
since: Ok(Default::default()),
until: 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 since<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.since = value
.try_into()
.map_err(|e| format!("error converting supplied value for since: {e}"));
self
}
pub fn 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.until = value
.try_into()
.map_err(|e| format!("error converting supplied value for until: {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?,
since: value.since?,
until: value.until?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ext: Ok(value.ext),
since: Ok(value.since),
until: Ok(value.until),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
mediators:
::std::result::Result<::std::vec::Vec<super::MediatorStats>, ::std::string::String>,
senders:
::std::result::Result<::std::vec::Vec<super::SenderLastSeen>, ::std::string::String>,
since: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
until:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
mediators: Err("no value supplied for mediators".to_string()),
senders: Err("no value supplied for senders".to_string()),
since: Ok(Default::default()),
until: Err("no value supplied for until".to_string()),
}
}
}
impl Response {
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 mediators<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::MediatorStats>>,
T::Error: ::std::fmt::Display,
{
self.mediators = value
.try_into()
.map_err(|e| format!("error converting supplied value for mediators: {e}"));
self
}
pub fn senders<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::SenderLastSeen>>,
T::Error: ::std::fmt::Display,
{
self.senders = value
.try_into()
.map_err(|e| format!("error converting supplied value for senders: {e}"));
self
}
pub fn since<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.since = value
.try_into()
.map_err(|e| format!("error converting supplied value for since: {e}"));
self
}
pub fn until<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.until = value
.try_into()
.map_err(|e| format!("error converting supplied value for until: {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 {
ext: value.ext?,
mediators: value.mediators?,
senders: value.senders?,
since: value.since?,
until: value.until?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
mediators: Ok(value.mediators),
senders: Ok(value.senders),
since: Ok(value.since),
until: Ok(value.until),
}
}
}
#[derive(Clone, Debug)]
pub struct SenderLastSeen {
last_seen_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
last_seen_mediator:
::std::result::Result<super::SenderLastSeenLastSeenMediator, ::std::string::String>,
last_seen_transport: ::std::result::Result<
::std::option::Option<super::SenderLastSeenLastSeenTransport>,
::std::string::String,
>,
sender_did: ::std::result::Result<super::SenderLastSeenSenderDid, ::std::string::String>,
}
impl ::std::default::Default for SenderLastSeen {
fn default() -> Self {
Self {
last_seen_at: Err("no value supplied for last_seen_at".to_string()),
last_seen_mediator: Err("no value supplied for last_seen_mediator".to_string()),
last_seen_transport: Ok(Default::default()),
sender_did: Err("no value supplied for sender_did".to_string()),
}
}
}
impl SenderLastSeen {
pub fn last_seen_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.last_seen_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for last_seen_at: {e}"));
self
}
pub fn last_seen_mediator<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SenderLastSeenLastSeenMediator>,
T::Error: ::std::fmt::Display,
{
self.last_seen_mediator = value.try_into().map_err(|e| {
format!("error converting supplied value for last_seen_mediator: {e}")
});
self
}
pub fn last_seen_transport<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::SenderLastSeenLastSeenTransport>,
>,
T::Error: ::std::fmt::Display,
{
self.last_seen_transport = value.try_into().map_err(|e| {
format!("error converting supplied value for last_seen_transport: {e}")
});
self
}
pub fn sender_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SenderLastSeenSenderDid>,
T::Error: ::std::fmt::Display,
{
self.sender_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for sender_did: {e}"));
self
}
}
impl ::std::convert::TryFrom<SenderLastSeen> for super::SenderLastSeen {
type Error = super::error::ConversionError;
fn try_from(
value: SenderLastSeen,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
last_seen_at: value.last_seen_at?,
last_seen_mediator: value.last_seen_mediator?,
last_seen_transport: value.last_seen_transport?,
sender_did: value.sender_did?,
})
}
}
impl ::std::convert::From<super::SenderLastSeen> for SenderLastSeen {
fn from(value: super::SenderLastSeen) -> Self {
Self {
last_seen_at: Ok(value.last_seen_at),
last_seen_mediator: Ok(value.last_seen_mediator),
last_seen_transport: Ok(value.last_seen_transport),
sender_did: Ok(value.sender_did),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/services/report/0.2";
const IS_PROOF_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\"},\"MediatorStats\":{\"additionalProperties\":false,\"properties\":{\"firstSeenAt\":{\"description\":\"The first arrival through it in the window.\",\"format\":\"date-time\",\"type\":\"string\"},\"inboundCount\":{\"description\":\"Messages that arrived through it in the window, over every mediated transport.\",\"minimum\":0,\"type\":\"integer\"},\"lastSeenAt\":{\"description\":\"The last arrival through it in the window.\",\"format\":\"date-time\",\"type\":\"string\"},\"mediatorDid\":{\"description\":\"The mediator the traffic arrived through.\",\"maxLength\":1000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"mediatorDid\",\"inboundCount\",\"firstSeenAt\",\"lastSeenAt\"],\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"mediators\":{\"description\":\"One entry per mediator that carried inbound traffic in the window.\",\"items\":{\"$ref\":\"#/$defs/MediatorStats\"},\"maxItems\":1000,\"type\":\"array\"},\"senders\":{\"description\":\"One entry per sender that reached the agent in the window.\",\"items\":{\"$ref\":\"#/$defs/SenderLastSeen\"},\"maxItems\":100000,\"type\":\"array\"},\"since\":{\"description\":\"The lower bound applied, when the request gave one.\",\"format\":\"date-time\",\"type\":\"string\"},\"until\":{\"description\":\"The upper bound applied — now, when the request gave none.\",\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"until\",\"mediators\",\"senders\"],\"title\":\"VTA Services Report — response payload\",\"type\":\"object\"},\"SenderLastSeen\":{\"additionalProperties\":false,\"properties\":{\"lastSeenAt\":{\"description\":\"When that message arrived.\",\"format\":\"date-time\",\"type\":\"string\"},\"lastSeenMediator\":{\"description\":\"The mediator its most recent message arrived through.\",\"maxLength\":1000,\"minLength\":1,\"type\":\"string\"},\"lastSeenTransport\":{\"description\":\"The mediated transport the sender's most recent message arrived by. Absent when the agent's telemetry did not record it.\",\"enum\":[\"didcomm\",\"tsp\"],\"type\":\"string\"},\"senderDid\":{\"description\":\"A sender that reached the agent in the window.\",\"maxLength\":1000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"senderDid\",\"lastSeenMediator\",\"lastSeenAt\"],\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vta/services/report/0.2\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Asks an agent for its per-mediator inbound counts and each sender's last-seen mediator over a time window. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"since\":{\"description\":\"Lower bound, RFC 3339. Absent means as far back as the agent's telemetry goes.\",\"format\":\"date-time\",\"type\":\"string\"},\"until\":{\"description\":\"Upper bound, RFC 3339. Absent means now.\",\"format\":\"date-time\",\"type\":\"string\"}},\"title\":\"VTA Services — Report — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/services/report/0.2#response";
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\"},\"MediatorStats\":{\"additionalProperties\":false,\"properties\":{\"firstSeenAt\":{\"description\":\"The first arrival through it in the window.\",\"format\":\"date-time\",\"type\":\"string\"},\"inboundCount\":{\"description\":\"Messages that arrived through it in the window, over every mediated transport.\",\"minimum\":0,\"type\":\"integer\"},\"lastSeenAt\":{\"description\":\"The last arrival through it in the window.\",\"format\":\"date-time\",\"type\":\"string\"},\"mediatorDid\":{\"description\":\"The mediator the traffic arrived through.\",\"maxLength\":1000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"mediatorDid\",\"inboundCount\",\"firstSeenAt\",\"lastSeenAt\"],\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"mediators\":{\"description\":\"One entry per mediator that carried inbound traffic in the window.\",\"items\":{\"$ref\":\"#/$defs/MediatorStats\"},\"maxItems\":1000,\"type\":\"array\"},\"senders\":{\"description\":\"One entry per sender that reached the agent in the window.\",\"items\":{\"$ref\":\"#/$defs/SenderLastSeen\"},\"maxItems\":100000,\"type\":\"array\"},\"since\":{\"description\":\"The lower bound applied, when the request gave one.\",\"format\":\"date-time\",\"type\":\"string\"},\"until\":{\"description\":\"The upper bound applied — now, when the request gave none.\",\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"until\",\"mediators\",\"senders\"],\"title\":\"VTA Services Report — response payload\",\"type\":\"object\"},\"SenderLastSeen\":{\"additionalProperties\":false,\"properties\":{\"lastSeenAt\":{\"description\":\"When that message arrived.\",\"format\":\"date-time\",\"type\":\"string\"},\"lastSeenMediator\":{\"description\":\"The mediator its most recent message arrived through.\",\"maxLength\":1000,\"minLength\":1,\"type\":\"string\"},\"lastSeenTransport\":{\"description\":\"The mediated transport the sender's most recent message arrived by. Absent when the agent's telemetry did not record it.\",\"enum\":[\"didcomm\",\"tsp\"],\"type\":\"string\"},\"senderDid\":{\"description\":\"A sender that reached the agent in the window.\",\"maxLength\":1000,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"senderDid\",\"lastSeenMediator\",\"lastSeenAt\"],\"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::INVALID_WINDOW];
/// 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/services/report:invalidWindow`
///
/// `since` is after `until`.
///
/// Declared `retryable: false`.
pub const INVALID_WINDOW: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/services/report:invalidWindow",
retryable: false,
details_schema: ::core::option::Option::None,
};
}