//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/queue/list`. 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 {
///Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<PayloadCursor>,
///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>,
///Maximum accounts per page. The mediator chooses a default when omitted.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<::std::num::NonZeroU64>,
///Omit accounts whose ranked queue holds fewer messages than this. Default 1 (skip empty queues).
#[serde(
rename = "minCount",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub min_count: ::std::option::Option<u64>,
///Which queue to rank by. Default `receive`.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub queue: ::std::option::Option<Queue>,
///Ranking key, descending. Default `count`.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub sort: ::std::option::Option<PayloadSort>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
cursor: Default::default(),
ext: Default::default(),
limit: Default::default(),
min_count: Default::default(),
queue: Default::default(),
sort: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCursor(::std::string::String);
impl ::std::ops::Deref for PayloadCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCursor> for ::std::string::String {
fn from(value: PayloadCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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())
})
}
}
///Ranking key, descending. Default `count`.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PayloadSort {
#[serde(rename = "count")]
Count,
#[serde(rename = "bytes")]
Bytes,
#[serde(rename = "oldest")]
Oldest,
#[serde(rename = "saturation")]
Saturation,
}
impl ::std::fmt::Display for PayloadSort {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Count => f.write_str("count"),
Self::Bytes => f.write_str("bytes"),
Self::Oldest => f.write_str("oldest"),
Self::Saturation => f.write_str("saturation"),
}
}
}
impl ::std::str::FromStr for PayloadSort {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"count" => Ok(Self::Count),
"bytes" => Ok(Self::Bytes),
"oldest" => Ok(Self::Oldest),
"saturation" => Ok(Self::Saturation),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PayloadSort {
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 PayloadSort {
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 PayloadSort {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Which of an account's two queues. `receive` holds messages addressed to the account awaiting its pickup. `send` holds messages the account sent that are still held against it until their recipient deletes them — so a stalled recipient fills its senders' send queues.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum Queue {
#[serde(rename = "receive")]
Receive,
#[serde(rename = "send")]
Send,
}
impl ::std::fmt::Display for Queue {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Receive => f.write_str("receive"),
Self::Send => f.write_str("send"),
}
}
}
impl ::std::str::FromStr for Queue {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"receive" => Ok(Self::Receive),
"send" => Ok(Self::Send),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for Queue {
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 Queue {
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 Queue {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///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/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/list/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>,
///Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub next_cursor: ::std::option::Option<ResponseNextCursor>,
pub queues: ::std::vec::Vec<QueueSummary>,
///When the ranking was computed. A mediator MAY serve the ranking from a periodic survey rather than a live scan.
#[serde(rename = "snapshotAt")]
pub snapshot_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The ranking did not cover every account.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub truncated: ::std::option::Option<bool>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseNextCursor(::std::string::String);
impl ::std::ops::Deref for ResponseNextCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseNextCursor> for ::std::string::String {
fn from(value: ResponseNextCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A 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 {
cursor: ::std::result::Result<
::std::option::Option<super::PayloadCursor>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
limit: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
min_count: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
queue: ::std::result::Result<::std::option::Option<super::Queue>, ::std::string::String>,
sort:
::std::result::Result<::std::option::Option<super::PayloadSort>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
cursor: Ok(Default::default()),
ext: Ok(Default::default()),
limit: Ok(Default::default()),
min_count: Ok(Default::default()),
queue: Ok(Default::default()),
sort: Ok(Default::default()),
}
}
}
impl Payload {
pub fn cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadCursor>>,
T::Error: ::std::fmt::Display,
{
self.cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for cursor: {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 limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn min_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.min_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for min_count: {e}"));
self
}
pub fn queue<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Queue>>,
T::Error: ::std::fmt::Display,
{
self.queue = value
.try_into()
.map_err(|e| format!("error converting supplied value for queue: {e}"));
self
}
pub fn sort<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadSort>>,
T::Error: ::std::fmt::Display,
{
self.sort = value
.try_into()
.map_err(|e| format!("error converting supplied value for sort: {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 {
cursor: value.cursor?,
ext: value.ext?,
limit: value.limit?,
min_count: value.min_count?,
queue: value.queue?,
sort: value.sort?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
cursor: Ok(value.cursor),
ext: Ok(value.ext),
limit: Ok(value.limit),
min_count: Ok(value.min_count),
queue: Ok(value.queue),
sort: Ok(value.sort),
}
}
}
#[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>,
next_cursor: ::std::result::Result<
::std::option::Option<super::ResponseNextCursor>,
::std::string::String,
>,
queues: ::std::result::Result<::std::vec::Vec<super::QueueSummary>, ::std::string::String>,
snapshot_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
truncated: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
next_cursor: Ok(Default::default()),
queues: Err("no value supplied for queues".to_string()),
snapshot_at: Err("no value supplied for snapshot_at".to_string()),
truncated: 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 next_cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseNextCursor>>,
T::Error: ::std::fmt::Display,
{
self.next_cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for next_cursor: {e}"));
self
}
pub fn queues<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<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 snapshot_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.snapshot_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for snapshot_at: {e}"));
self
}
pub fn truncated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.truncated = value
.try_into()
.map_err(|e| format!("error converting supplied value for truncated: {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?,
next_cursor: value.next_cursor?,
queues: value.queues?,
snapshot_at: value.snapshot_at?,
truncated: value.truncated?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
next_cursor: Ok(value.next_cursor),
queues: Ok(value.queues),
snapshot_at: Ok(value.snapshot_at),
truncated: Ok(value.truncated),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/queue/list/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\"},\"Queue\":{\"description\":\"Which of an account's two queues. `receive` holds messages addressed to the account awaiting its pickup. `send` holds messages the account sent that are still held against it until their recipient deletes them — so a stalled recipient fills its senders' send queues.\",\"enum\":[\"receive\",\"send\"],\"title\":\"Queue\",\"type\":\"string\"},\"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/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/list/0.1#response.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"nextCursor\":{\"description\":\"Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.\",\"minLength\":1,\"type\":\"string\"},\"queues\":{\"items\":{\"$ref\":\"#/$defs/QueueSummary\"},\"type\":\"array\"},\"snapshotAt\":{\"description\":\"When the ranking was computed. A mediator MAY serve the ranking from a periodic survey rather than a live scan.\",\"format\":\"date-time\",\"type\":\"string\"},\"truncated\":{\"description\":\"The ranking did not cover every account.\",\"type\":\"boolean\"}},\"required\":[\"queues\",\"snapshotAt\"],\"title\":\"Messaging — List Queues — 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/list/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"properties\":{\"cursor\":{\"description\":\"Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.\",\"minLength\":1,\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"limit\":{\"description\":\"Maximum accounts per page. The mediator chooses a default when omitted.\",\"maximum\":500,\"minimum\":1,\"type\":\"integer\"},\"minCount\":{\"description\":\"Omit accounts whose ranked queue holds fewer messages than this. Default 1 (skip empty queues).\",\"minimum\":0,\"type\":\"integer\"},\"queue\":{\"$ref\":\"#/$defs/Queue\",\"description\":\"Which queue to rank by. Default `receive`.\"},\"sort\":{\"description\":\"Ranking key, descending. Default `count`.\",\"enum\":[\"count\",\"bytes\",\"oldest\",\"saturation\"],\"type\":\"string\"}},\"title\":\"Messaging — List Queues — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/queue/list/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\"},\"Queue\":{\"description\":\"Which of an account's two queues. `receive` holds messages addressed to the account awaiting its pickup. `send` holds messages the account sent that are still held against it until their recipient deletes them — so a stalled recipient fills its senders' send queues.\",\"enum\":[\"receive\",\"send\"],\"title\":\"Queue\",\"type\":\"string\"},\"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/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/list/0.1#response.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"nextCursor\":{\"description\":\"Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.\",\"minLength\":1,\"type\":\"string\"},\"queues\":{\"items\":{\"$ref\":\"#/$defs/QueueSummary\"},\"type\":\"array\"},\"snapshotAt\":{\"description\":\"When the ranking was computed. A mediator MAY serve the ranking from a periodic survey rather than a live scan.\",\"format\":\"date-time\",\"type\":\"string\"},\"truncated\":{\"description\":\"The ranking did not cover every account.\",\"type\":\"boolean\"}},\"required\":[\"queues\",\"snapshotAt\"],\"title\":\"Messaging — List Queues — 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] = &[];