//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/queue/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())
}
}
}
///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.
///
#[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.
///
#[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 {
///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.
///
#[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.
///
#[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.
///
#[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.
///
#[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.
///
#[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(
"{\"$defs\":{\"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.\",\"enum\":[\"standard\",\"admin\",\"rootAdmin\",\"mediator\"],\"title\":\"AccountType\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"PeerDepth\":{\"additionalProperties\":false,\"description\":\"The share of one queue attributable to one counterparty: in a send queue, the recipient; in a receive queue, the sender.\",\"properties\":{\"bytes\":{\"minimum\":0,\"type\":\"integer\"},\"count\":{\"minimum\":0,\"type\":\"integer\"},\"oldestAgeSeconds\":{\"minimum\":0,\"type\":\"integer\"},\"peer\":{\"$ref\":\"#/$defs/Vid\",\"description\":\"The counterparty's identifier, in the same form the mediator uses for accounts.\"}},\"required\":[\"peer\",\"count\",\"bytes\"],\"title\":\"PeerDepth\",\"type\":\"object\"},\"QueueDepth\":{\"additionalProperties\":false,\"description\":\"The depth of one queue and its effective limit.\",\"properties\":{\"bytes\":{\"description\":\"Total stored size of those messages, in bytes.\",\"minimum\":0,\"type\":\"integer\"},\"count\":{\"description\":\"Messages currently in the queue.\",\"minimum\":0,\"type\":\"integer\"},\"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.\",\"minimum\":0,\"type\":\"integer\"},\"limit\":{\"description\":\"The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.\",\"minimum\":-1,\"type\":\"integer\"},\"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.\",\"minimum\":0,\"type\":\"integer\"},\"saturation\":{\"description\":\"count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.\",\"minimum\":0,\"type\":\"number\"}},\"required\":[\"count\",\"bytes\"],\"title\":\"QueueDepth\",\"type\":\"object\"},\"QueueSummary\":{\"additionalProperties\":false,\"description\":\"Both queues of one account.\",\"properties\":{\"accountType\":{\"$ref\":\"#/$defs/AccountType\"},\"did\":{\"$ref\":\"#/$defs/Vid\"},\"receive\":{\"$ref\":\"#/$defs/QueueDepth\"},\"send\":{\"$ref\":\"#/$defs/QueueDepth\"}},\"required\":[\"did\",\"receive\",\"send\"],\"title\":\"QueueSummary\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"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.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"queues\":{\"$ref\":\"#/$defs/QueueSummary\"},\"receivePeers\":{\"description\":\"Top senders into the receive queue. Present only when includePeers was requested.\",\"items\":{\"$ref\":\"#/$defs/PeerDepth\"},\"type\":\"array\"},\"sendPeers\":{\"description\":\"Top recipients holding the send queue. Present only when includePeers was requested.\",\"items\":{\"$ref\":\"#/$defs/PeerDepth\"},\"type\":\"array\"}},\"required\":[\"queues\"],\"title\":\"Messaging — Show Queue Status — response payload\",\"type\":\"object\"},\"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.\",\"minLength\":1,\"title\":\"Vid\",\"type\":\"string\"}},\"$id\":\"https://trusttasks.org/spec/messaging/queue/status/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"properties\":{\"did\":{\"$ref\":\"#/$defs/Vid\",\"description\":\"The account whose queues to report. Omitted = the requester's own account. A requester without administrative standing may name only itself.\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"includePeers\":{\"description\":\"Also return the top N counterparties of each queue by message count. Omitted = no per-peer breakdown.\",\"maximum\":100,\"minimum\":1,\"type\":\"integer\"}},\"title\":\"Messaging — Show Queue Status — payload\",\"type\":\"object\"}\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(
"{\"$defs\":{\"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.\",\"enum\":[\"standard\",\"admin\",\"rootAdmin\",\"mediator\"],\"title\":\"AccountType\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"PeerDepth\":{\"additionalProperties\":false,\"description\":\"The share of one queue attributable to one counterparty: in a send queue, the recipient; in a receive queue, the sender.\",\"properties\":{\"bytes\":{\"minimum\":0,\"type\":\"integer\"},\"count\":{\"minimum\":0,\"type\":\"integer\"},\"oldestAgeSeconds\":{\"minimum\":0,\"type\":\"integer\"},\"peer\":{\"$ref\":\"#/$defs/Vid\",\"description\":\"The counterparty's identifier, in the same form the mediator uses for accounts.\"}},\"required\":[\"peer\",\"count\",\"bytes\"],\"title\":\"PeerDepth\",\"type\":\"object\"},\"QueueDepth\":{\"additionalProperties\":false,\"description\":\"The depth of one queue and its effective limit.\",\"properties\":{\"bytes\":{\"description\":\"Total stored size of those messages, in bytes.\",\"minimum\":0,\"type\":\"integer\"},\"count\":{\"description\":\"Messages currently in the queue.\",\"minimum\":0,\"type\":\"integer\"},\"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.\",\"minimum\":0,\"type\":\"integer\"},\"limit\":{\"description\":\"The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.\",\"minimum\":-1,\"type\":\"integer\"},\"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.\",\"minimum\":0,\"type\":\"integer\"},\"saturation\":{\"description\":\"count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.\",\"minimum\":0,\"type\":\"number\"}},\"required\":[\"count\",\"bytes\"],\"title\":\"QueueDepth\",\"type\":\"object\"},\"QueueSummary\":{\"additionalProperties\":false,\"description\":\"Both queues of one account.\",\"properties\":{\"accountType\":{\"$ref\":\"#/$defs/AccountType\"},\"did\":{\"$ref\":\"#/$defs/Vid\"},\"receive\":{\"$ref\":\"#/$defs/QueueDepth\"},\"send\":{\"$ref\":\"#/$defs/QueueDepth\"}},\"required\":[\"did\",\"receive\",\"send\"],\"title\":\"QueueSummary\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"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.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"queues\":{\"$ref\":\"#/$defs/QueueSummary\"},\"receivePeers\":{\"description\":\"Top senders into the receive queue. Present only when includePeers was requested.\",\"items\":{\"$ref\":\"#/$defs/PeerDepth\"},\"type\":\"array\"},\"sendPeers\":{\"description\":\"Top recipients holding the send queue. Present only when includePeers was requested.\",\"items\":{\"$ref\":\"#/$defs/PeerDepth\"},\"type\":\"array\"}},\"required\":[\"queues\"],\"title\":\"Messaging — Show Queue Status — response payload\",\"type\":\"object\"},\"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.\",\"minLength\":1,\"title\":\"Vid\",\"type\":\"string\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[error_codes::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,
details_schema: ::core::option::Option::None,
};
}