//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/queue/status`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///The account's role at the mediator. `standard` is an ordinary served account; `admin`/`rootAdmin` may administer other accounts; `mediator` is the mediator's own account. Only a rootAdmin may assign or modify the rootAdmin role.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "AccountType",
/// "description": "The account's role at the mediator. `standard` is an ordinary served account; `admin`/`rootAdmin` may administer other accounts; `mediator` is the mediator's own account. Only a rootAdmin may assign or modify the rootAdmin role.",
/// "type": "string",
/// "enum": [
/// "standard",
/// "admin",
/// "rootAdmin",
/// "mediator"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum AccountType {
#[serde(rename = "standard")]
Standard,
#[serde(rename = "admin")]
Admin,
#[serde(rename = "rootAdmin")]
RootAdmin,
#[serde(rename = "mediator")]
Mediator,
}
impl ::std::fmt::Display for AccountType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Standard => f.write_str("standard"),
Self::Admin => f.write_str("admin"),
Self::RootAdmin => f.write_str("rootAdmin"),
Self::Mediator => f.write_str("mediator"),
}
}
}
impl ::std::str::FromStr for AccountType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"standard" => Ok(Self::Standard),
"admin" => Ok(Self::Admin),
"rootAdmin" => Ok(Self::RootAdmin),
"mediator" => Ok(Self::Mediator),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for AccountType {
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 AccountType {
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 AccountType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Payload`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/messaging/queue/status/0.1",
/// "title": "Payload",
/// "type": "object",
/// "properties": {
/// "did": {
/// "description": "The account whose queues to report. Omitted = the requester's own account. A requester without administrative standing may name only itself.",
/// "$ref": "#/definitions/Vid"
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "includePeers": {
/// "description": "Also return the top N counterparties of each queue by message count. Omitted = no per-peer breakdown.",
/// "type": "integer",
/// "maximum": 100.0,
/// "minimum": 1.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The account whose queues to report. Omitted = the requester's own account. A requester without administrative standing may name only itself.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub did: ::std::option::Option<Vid>,
///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>,
///Also return the top N counterparties of each queue by message count. Omitted = no per-peer breakdown.
#[serde(
rename = "includePeers",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub include_peers: ::std::option::Option<::std::num::NonZeroU64>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
did: Default::default(),
ext: Default::default(),
include_peers: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The share of one queue attributable to one counterparty: in a send queue, the recipient; in a receive queue, the sender.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "PeerDepth",
/// "description": "The share of one queue attributable to one counterparty: in a send queue, the recipient; in a receive queue, the sender.",
/// "type": "object",
/// "required": [
/// "bytes",
/// "count",
/// "peer"
/// ],
/// "properties": {
/// "bytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "count": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "oldestAgeSeconds": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "peer": {
/// "description": "The counterparty's identifier, in the same form the mediator uses for accounts.",
/// "$ref": "#/definitions/Vid"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PeerDepth {
pub bytes: u64,
pub count: u64,
#[serde(
rename = "oldestAgeSeconds",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub oldest_age_seconds: ::std::option::Option<u64>,
///The counterparty's identifier, in the same form the mediator uses for accounts.
pub peer: Vid,
}
impl PeerDepth {
pub fn builder() -> builder::PeerDepth {
Default::default()
}
}
///The depth of one queue and its effective limit.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QueueDepth",
/// "description": "The depth of one queue and its effective limit.",
/// "type": "object",
/// "required": [
/// "bytes",
/// "count"
/// ],
/// "properties": {
/// "bytes": {
/// "description": "Total stored size of those messages, in bytes.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "count": {
/// "description": "Messages currently in the queue.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "deliveredUnacked": {
/// "description": "Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "limit": {
/// "description": "The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.",
/// "type": "integer",
/// "minimum": -1.0
/// },
/// "oldestAgeSeconds": {
/// "description": "Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "saturation": {
/// "description": "count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.",
/// "type": "number",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QueueDepth {
///Total stored size of those messages, in bytes.
pub bytes: u64,
///Messages currently in the queue.
pub count: u64,
///Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.
#[serde(
rename = "deliveredUnacked",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub delivered_unacked: ::std::option::Option<u64>,
///The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<i64>,
///Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.
#[serde(
rename = "oldestAgeSeconds",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub oldest_age_seconds: ::std::option::Option<u64>,
///count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub saturation: ::std::option::Option<f64>,
}
impl QueueDepth {
pub fn builder() -> builder::QueueDepth {
Default::default()
}
}
///Both queues of one account.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QueueSummary",
/// "description": "Both queues of one account.",
/// "type": "object",
/// "required": [
/// "did",
/// "receive",
/// "send"
/// ],
/// "properties": {
/// "accountType": {
/// "$ref": "#/definitions/AccountType"
/// },
/// "did": {
/// "$ref": "#/definitions/Vid"
/// },
/// "receive": {
/// "$ref": "#/definitions/QueueDepth"
/// },
/// "send": {
/// "$ref": "#/definitions/QueueDepth"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QueueSummary {
#[serde(
rename = "accountType",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub account_type: ::std::option::Option<AccountType>,
pub did: Vid,
pub receive: QueueDepth,
pub send: QueueDepth,
}
impl QueueSummary {
pub fn builder() -> builder::QueueSummary {
Default::default()
}
}
///The success response to a messaging/queue/status request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/status/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The success response to a messaging/queue/status request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/status/0.1#response.",
/// "type": "object",
/// "required": [
/// "queues"
/// ],
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "queues": {
/// "$ref": "#/definitions/QueueSummary"
/// },
/// "receivePeers": {
/// "description": "Top senders into the receive queue. Present only when includePeers was requested.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/PeerDepth"
/// }
/// },
/// "sendPeers": {
/// "description": "Top recipients holding the send queue. Present only when includePeers was requested.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/PeerDepth"
/// }
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[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>,
pub queues: QueueSummary,
///Top senders into the receive queue. Present only when includePeers was requested.
#[serde(
rename = "receivePeers",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub receive_peers: ::std::vec::Vec<PeerDepth>,
///Top recipients holding the send queue. Present only when includePeers was requested.
#[serde(
rename = "sendPeers",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub send_peers: ::std::vec::Vec<PeerDepth>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///A Verifiable Identifier (SPEC §4.8). For a mediator-served account this is the account's controlling DID, carried verbatim and compared by exact string equality. For privacy — and because some mediators key accounts by a one-way hash and never hold the full DID — a stable hash of the DID (e.g. its SHA-256 digest) is an equally valid value here: producer and consumer simply agree on the same opaque identifier and compare by exact string equality. The field carries whichever form the issuing mediator uses.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Vid",
/// "description": "A Verifiable Identifier (SPEC §4.8). For a mediator-served account this is the account's controlling DID, carried verbatim and compared by exact string equality. For privacy — and because some mediators key accounts by a one-way hash and never hold the full DID — a stable hash of the DID (e.g. its SHA-256 digest) is an equally valid value here: producer and consumer simply agree on the same opaque identifier and compare by exact string equality. The field carries whichever form the issuing mediator uses.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Vid(::std::string::String);
impl ::std::ops::Deref for Vid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Vid> for ::std::string::String {
fn from(value: Vid) -> Self {
value.0
}
}
impl ::std::str::FromStr for Vid {
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 Vid {
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 Vid {
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 Vid {
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 Vid {
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 Payload {
did: ::std::result::Result<::std::option::Option<super::Vid>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
include_peers: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
did: Ok(Default::default()),
ext: Ok(Default::default()),
include_peers: Ok(Default::default()),
}
}
}
impl Payload {
pub fn did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Vid>>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for 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_peers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.include_peers = value
.try_into()
.map_err(|e| format!("error converting supplied value for include_peers: {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 {
did: value.did?,
ext: value.ext?,
include_peers: value.include_peers?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
did: Ok(value.did),
ext: Ok(value.ext),
include_peers: Ok(value.include_peers),
}
}
}
#[derive(Clone, Debug)]
pub struct PeerDepth {
bytes: ::std::result::Result<u64, ::std::string::String>,
count: ::std::result::Result<u64, ::std::string::String>,
oldest_age_seconds:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
peer: ::std::result::Result<super::Vid, ::std::string::String>,
}
impl ::std::default::Default for PeerDepth {
fn default() -> Self {
Self {
bytes: Err("no value supplied for bytes".to_string()),
count: Err("no value supplied for count".to_string()),
oldest_age_seconds: Ok(Default::default()),
peer: Err("no value supplied for peer".to_string()),
}
}
}
impl PeerDepth {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.count = value
.try_into()
.map_err(|e| format!("error converting supplied value for count: {e}"));
self
}
pub fn oldest_age_seconds<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.oldest_age_seconds = value.try_into().map_err(|e| {
format!("error converting supplied value for oldest_age_seconds: {e}")
});
self
}
pub fn peer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Vid>,
T::Error: ::std::fmt::Display,
{
self.peer = value
.try_into()
.map_err(|e| format!("error converting supplied value for peer: {e}"));
self
}
}
impl ::std::convert::TryFrom<PeerDepth> for super::PeerDepth {
type Error = super::error::ConversionError;
fn try_from(
value: PeerDepth,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
count: value.count?,
oldest_age_seconds: value.oldest_age_seconds?,
peer: value.peer?,
})
}
}
impl ::std::convert::From<super::PeerDepth> for PeerDepth {
fn from(value: super::PeerDepth) -> Self {
Self {
bytes: Ok(value.bytes),
count: Ok(value.count),
oldest_age_seconds: Ok(value.oldest_age_seconds),
peer: Ok(value.peer),
}
}
}
#[derive(Clone, Debug)]
pub struct QueueDepth {
bytes: ::std::result::Result<u64, ::std::string::String>,
count: ::std::result::Result<u64, ::std::string::String>,
delivered_unacked: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
limit: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
oldest_age_seconds:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
saturation: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
}
impl ::std::default::Default for QueueDepth {
fn default() -> Self {
Self {
bytes: Err("no value supplied for bytes".to_string()),
count: Err("no value supplied for count".to_string()),
delivered_unacked: Ok(Default::default()),
limit: Ok(Default::default()),
oldest_age_seconds: Ok(Default::default()),
saturation: Ok(Default::default()),
}
}
}
impl QueueDepth {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.count = value
.try_into()
.map_err(|e| format!("error converting supplied value for count: {e}"));
self
}
pub fn delivered_unacked<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.delivered_unacked = value
.try_into()
.map_err(|e| format!("error converting supplied value for delivered_unacked: {e}"));
self
}
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn oldest_age_seconds<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.oldest_age_seconds = value.try_into().map_err(|e| {
format!("error converting supplied value for oldest_age_seconds: {e}")
});
self
}
pub fn saturation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.saturation = value
.try_into()
.map_err(|e| format!("error converting supplied value for saturation: {e}"));
self
}
}
impl ::std::convert::TryFrom<QueueDepth> for super::QueueDepth {
type Error = super::error::ConversionError;
fn try_from(
value: QueueDepth,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
count: value.count?,
delivered_unacked: value.delivered_unacked?,
limit: value.limit?,
oldest_age_seconds: value.oldest_age_seconds?,
saturation: value.saturation?,
})
}
}
impl ::std::convert::From<super::QueueDepth> for QueueDepth {
fn from(value: super::QueueDepth) -> Self {
Self {
bytes: Ok(value.bytes),
count: Ok(value.count),
delivered_unacked: Ok(value.delivered_unacked),
limit: Ok(value.limit),
oldest_age_seconds: Ok(value.oldest_age_seconds),
saturation: Ok(value.saturation),
}
}
}
#[derive(Clone, Debug)]
pub struct QueueSummary {
account_type:
::std::result::Result<::std::option::Option<super::AccountType>, ::std::string::String>,
did: ::std::result::Result<super::Vid, ::std::string::String>,
receive: ::std::result::Result<super::QueueDepth, ::std::string::String>,
send: ::std::result::Result<super::QueueDepth, ::std::string::String>,
}
impl ::std::default::Default for QueueSummary {
fn default() -> Self {
Self {
account_type: Ok(Default::default()),
did: Err("no value supplied for did".to_string()),
receive: Err("no value supplied for receive".to_string()),
send: Err("no value supplied for send".to_string()),
}
}
}
impl QueueSummary {
pub fn account_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::AccountType>>,
T::Error: ::std::fmt::Display,
{
self.account_type = value
.try_into()
.map_err(|e| format!("error converting supplied value for account_type: {e}"));
self
}
pub fn did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Vid>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {e}"));
self
}
pub fn receive<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::QueueDepth>,
T::Error: ::std::fmt::Display,
{
self.receive = value
.try_into()
.map_err(|e| format!("error converting supplied value for receive: {e}"));
self
}
pub fn send<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::QueueDepth>,
T::Error: ::std::fmt::Display,
{
self.send = value
.try_into()
.map_err(|e| format!("error converting supplied value for send: {e}"));
self
}
}
impl ::std::convert::TryFrom<QueueSummary> for super::QueueSummary {
type Error = super::error::ConversionError;
fn try_from(
value: QueueSummary,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
account_type: value.account_type?,
did: value.did?,
receive: value.receive?,
send: value.send?,
})
}
}
impl ::std::convert::From<super::QueueSummary> for QueueSummary {
fn from(value: super::QueueSummary) -> Self {
Self {
account_type: Ok(value.account_type),
did: Ok(value.did),
receive: Ok(value.receive),
send: Ok(value.send),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
queues: ::std::result::Result<super::QueueSummary, ::std::string::String>,
receive_peers:
::std::result::Result<::std::vec::Vec<super::PeerDepth>, ::std::string::String>,
send_peers: ::std::result::Result<::std::vec::Vec<super::PeerDepth>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
queues: Err("no value supplied for queues".to_string()),
receive_peers: Ok(Default::default()),
send_peers: Ok(Default::default()),
}
}
}
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 queues<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::QueueSummary>,
T::Error: ::std::fmt::Display,
{
self.queues = value
.try_into()
.map_err(|e| format!("error converting supplied value for queues: {e}"));
self
}
pub fn receive_peers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PeerDepth>>,
T::Error: ::std::fmt::Display,
{
self.receive_peers = value
.try_into()
.map_err(|e| format!("error converting supplied value for receive_peers: {e}"));
self
}
pub fn send_peers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PeerDepth>>,
T::Error: ::std::fmt::Display,
{
self.send_peers = value
.try_into()
.map_err(|e| format!("error converting supplied value for send_peers: {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?,
queues: value.queues?,
receive_peers: value.receive_peers?,
send_peers: value.send_peers?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
queues: Ok(value.queues),
receive_peers: Ok(value.receive_peers),
send_peers: Ok(value.send_peers),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/queue/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(
"{\n \"$defs\": {\n \"AccountType\": {\n \"description\": \"The account's role at the mediator. `standard` is an ordinary served account; `admin`/`rootAdmin` may administer other accounts; `mediator` is the mediator's own account. Only a rootAdmin may assign or modify the rootAdmin role.\",\n \"enum\": [\n \"standard\",\n \"admin\",\n \"rootAdmin\",\n \"mediator\"\n ],\n \"title\": \"AccountType\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"PeerDepth\": {\n \"additionalProperties\": false,\n \"description\": \"The share of one queue attributable to one counterparty: in a send queue, the recipient; in a receive queue, the sender.\",\n \"properties\": {\n \"bytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"count\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"oldestAgeSeconds\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"peer\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The counterparty's identifier, in the same form the mediator uses for accounts.\"\n }\n },\n \"required\": [\n \"peer\",\n \"count\",\n \"bytes\"\n ],\n \"title\": \"PeerDepth\",\n \"type\": \"object\"\n },\n \"QueueDepth\": {\n \"additionalProperties\": false,\n \"description\": \"The depth of one queue and its effective limit.\",\n \"properties\": {\n \"bytes\": {\n \"description\": \"Total stored size of those messages, in bytes.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"count\": {\n \"description\": \"Messages currently in the queue.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"deliveredUnacked\": {\n \"description\": \"Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"limit\": {\n \"description\": \"The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.\",\n \"minimum\": -1,\n \"type\": \"integer\"\n },\n \"oldestAgeSeconds\": {\n \"description\": \"Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"saturation\": {\n \"description\": \"count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.\",\n \"minimum\": 0,\n \"type\": \"number\"\n }\n },\n \"required\": [\n \"count\",\n \"bytes\"\n ],\n \"title\": \"QueueDepth\",\n \"type\": \"object\"\n },\n \"QueueSummary\": {\n \"additionalProperties\": false,\n \"description\": \"Both queues of one account.\",\n \"properties\": {\n \"accountType\": {\n \"$ref\": \"#/$defs/AccountType\"\n },\n \"did\": {\n \"$ref\": \"#/$defs/Vid\"\n },\n \"receive\": {\n \"$ref\": \"#/$defs/QueueDepth\"\n },\n \"send\": {\n \"$ref\": \"#/$defs/QueueDepth\"\n }\n },\n \"required\": [\n \"did\",\n \"receive\",\n \"send\"\n ],\n \"title\": \"QueueSummary\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a messaging/queue/status request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/status/0.1#response.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"queues\": {\n \"$ref\": \"#/$defs/QueueSummary\"\n },\n \"receivePeers\": {\n \"description\": \"Top senders into the receive queue. Present only when includePeers was requested.\",\n \"items\": {\n \"$ref\": \"#/$defs/PeerDepth\"\n },\n \"type\": \"array\"\n },\n \"sendPeers\": {\n \"description\": \"Top recipients holding the send queue. Present only when includePeers was requested.\",\n \"items\": {\n \"$ref\": \"#/$defs/PeerDepth\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"queues\"\n ],\n \"title\": \"Messaging — Show Queue Status — response payload\",\n \"type\": \"object\"\n },\n \"Vid\": {\n \"description\": \"A Verifiable Identifier (SPEC §4.8). For a mediator-served account this is the account's controlling DID, carried verbatim and compared by exact string equality. For privacy — and because some mediators key accounts by a one-way hash and never hold the full DID — a stable hash of the DID (e.g. its SHA-256 digest) is an equally valid value here: producer and consumer simply agree on the same opaque identifier and compare by exact string equality. The field carries whichever form the issuing mediator uses.\",\n \"minLength\": 1,\n \"title\": \"Vid\",\n \"type\": \"string\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/messaging/queue/status/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"properties\": {\n \"did\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The account whose queues to report. Omitted = the requester's own account. A requester without administrative standing may name only itself.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"includePeers\": {\n \"description\": \"Also return the top N counterparties of each queue by message count. Omitted = no per-peer breakdown.\",\n \"maximum\": 100,\n \"minimum\": 1,\n \"type\": \"integer\"\n }\n },\n \"title\": \"Messaging — Show Queue Status — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/messaging/queue/status/0.1#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"AccountType\": {\n \"description\": \"The account's role at the mediator. `standard` is an ordinary served account; `admin`/`rootAdmin` may administer other accounts; `mediator` is the mediator's own account. Only a rootAdmin may assign or modify the rootAdmin role.\",\n \"enum\": [\n \"standard\",\n \"admin\",\n \"rootAdmin\",\n \"mediator\"\n ],\n \"title\": \"AccountType\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"PeerDepth\": {\n \"additionalProperties\": false,\n \"description\": \"The share of one queue attributable to one counterparty: in a send queue, the recipient; in a receive queue, the sender.\",\n \"properties\": {\n \"bytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"count\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"oldestAgeSeconds\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"peer\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The counterparty's identifier, in the same form the mediator uses for accounts.\"\n }\n },\n \"required\": [\n \"peer\",\n \"count\",\n \"bytes\"\n ],\n \"title\": \"PeerDepth\",\n \"type\": \"object\"\n },\n \"QueueDepth\": {\n \"additionalProperties\": false,\n \"description\": \"The depth of one queue and its effective limit.\",\n \"properties\": {\n \"bytes\": {\n \"description\": \"Total stored size of those messages, in bytes.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"count\": {\n \"description\": \"Messages currently in the queue.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"deliveredUnacked\": {\n \"description\": \"Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"limit\": {\n \"description\": \"The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.\",\n \"minimum\": -1,\n \"type\": \"integer\"\n },\n \"oldestAgeSeconds\": {\n \"description\": \"Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"saturation\": {\n \"description\": \"count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.\",\n \"minimum\": 0,\n \"type\": \"number\"\n }\n },\n \"required\": [\n \"count\",\n \"bytes\"\n ],\n \"title\": \"QueueDepth\",\n \"type\": \"object\"\n },\n \"QueueSummary\": {\n \"additionalProperties\": false,\n \"description\": \"Both queues of one account.\",\n \"properties\": {\n \"accountType\": {\n \"$ref\": \"#/$defs/AccountType\"\n },\n \"did\": {\n \"$ref\": \"#/$defs/Vid\"\n },\n \"receive\": {\n \"$ref\": \"#/$defs/QueueDepth\"\n },\n \"send\": {\n \"$ref\": \"#/$defs/QueueDepth\"\n }\n },\n \"required\": [\n \"did\",\n \"receive\",\n \"send\"\n ],\n \"title\": \"QueueSummary\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a messaging/queue/status request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/status/0.1#response.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"queues\": {\n \"$ref\": \"#/$defs/QueueSummary\"\n },\n \"receivePeers\": {\n \"description\": \"Top senders into the receive queue. Present only when includePeers was requested.\",\n \"items\": {\n \"$ref\": \"#/$defs/PeerDepth\"\n },\n \"type\": \"array\"\n },\n \"sendPeers\": {\n \"description\": \"Top recipients holding the send queue. Present only when includePeers was requested.\",\n \"items\": {\n \"$ref\": \"#/$defs/PeerDepth\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"queues\"\n ],\n \"title\": \"Messaging — Show Queue Status — response payload\",\n \"type\": \"object\"\n },\n \"Vid\": {\n \"description\": \"A Verifiable Identifier (SPEC §4.8). For a mediator-served account this is the account's controlling DID, carried verbatim and compared by exact string equality. For privacy — and because some mediators key accounts by a one-way hash and never hold the full DID — a stable hash of the DID (e.g. its SHA-256 digest) is an equally valid value here: producer and consumer simply agree on the same opaque identifier and compare by exact string equality. The field carries whichever form the issuing mediator uses.\",\n \"minLength\": 1,\n \"title\": \"Vid\",\n \"type\": \"string\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// 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::UNKNOWN_ACCOUNT];
/// 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 {
/// `messaging/queue/status:unknownAccount`
///
/// The named account does not exist at this mediator.
///
/// Declared `retryable: false`.
pub const UNKNOWN_ACCOUNT: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "messaging/queue/status:unknownAccount",
retryable: false,
};
}
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
#[test]
fn request_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:9a4c1e7b-2d5f-4a80-b3c6-8e1f0d2a3b01\",\n \"type\": \"https://trusttasks.org/spec/messaging/queue/status/0.1\",\n \"issuer\": \"did:web:admin.example\",\n \"recipient\": \"did:web:mediator.example\",\n \"issuedAt\": \"2026-09-21T10:07:00Z\",\n \"payload\": {\n \"did\": \"did:web:alice.example\",\n \"includePeers\": 5\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:web:admin.example#key-1\",\n \"created\": \"2026-09-21T10:07:00Z\",\n \"proofPurpose\": \"assertionMethod\",\n \"proofValue\": \"z5Tr...\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn response_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:9a4c1e7b-2d5f-4a80-b3c6-8e1f0d2a3b02\",\n \"type\": \"https://trusttasks.org/spec/messaging/queue/status/0.1#response\",\n \"threadId\": \"urn:uuid:9a4c1e7b-2d5f-4a80-b3c6-8e1f0d2a3b01\",\n \"issuer\": \"did:web:mediator.example\",\n \"recipient\": \"did:web:admin.example\",\n \"issuedAt\": \"2026-09-21T10:07:00Z\",\n \"payload\": {\n \"queues\": {\n \"did\": \"did:web:alice.example\",\n \"accountType\": \"standard\",\n \"receive\": { \"count\": 2, \"bytes\": 4810, \"limit\": 1000, \"saturation\": 0.002, \"oldestAgeSeconds\": 40 },\n \"send\": { \"count\": 931, \"bytes\": 1804412, \"limit\": 1000, \"saturation\": 0.931, \"oldestAgeSeconds\": 86112, \"deliveredUnacked\": 931 }\n },\n \"receivePeers\": [\n { \"peer\": \"did:web:bob.example\", \"count\": 2, \"bytes\": 4810, \"oldestAgeSeconds\": 40 }\n ],\n \"sendPeers\": [\n { \"peer\": \"did:web:carol.example\", \"count\": 927, \"bytes\": 1796001, \"oldestAgeSeconds\": 86112 },\n { \"peer\": \"did:web:bob.example\", \"count\": 4, \"bytes\": 8411, \"oldestAgeSeconds\": 12 }\n ]\n }\n}\n";
let doc: crate::TrustTask<super::Response> =
serde_json::from_str(JSON).expect("deserialize response example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "response example failed round-trip");
}
}