//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/queue/list`. 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/list/0.1",
/// "title": "Payload",
/// "type": "object",
/// "properties": {
/// "cursor": {
/// "description": "Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.",
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "limit": {
/// "description": "Maximum accounts per page. The mediator chooses a default when omitted.",
/// "type": "integer",
/// "maximum": 500.0,
/// "minimum": 1.0
/// },
/// "minCount": {
/// "description": "Omit accounts whose ranked queue holds fewer messages than this. Default 1 (skip empty queues).",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "queue": {
/// "description": "Which queue to rank by. Default `receive`.",
/// "$ref": "#/definitions/Queue"
/// },
/// "sort": {
/// "description": "Ranking key, descending. Default `count`.",
/// "type": "string",
/// "enum": [
/// "count",
/// "bytes",
/// "oldest",
/// "saturation"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[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.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[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`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Ranking key, descending. Default `count`.",
/// "type": "string",
/// "enum": [
/// "count",
/// "bytes",
/// "oldest",
/// "saturation"
/// ]
///}
/// ```
/// </details>
#[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.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "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.",
/// "type": "string",
/// "enum": [
/// "receive",
/// "send"
/// ]
///}
/// ```
/// </details>
#[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.
///
/// <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/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/list/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "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.",
/// "type": "object",
/// "required": [
/// "queues",
/// "snapshotAt"
/// ],
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "nextCursor": {
/// "description": "Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.",
/// "type": "string",
/// "minLength": 1
/// },
/// "queues": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QueueSummary"
/// }
/// },
/// "snapshotAt": {
/// "description": "When the ranking was computed. A mediator MAY serve the ranking from a periodic survey rather than a live scan.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "truncated": {
/// "description": "The ranking did not cover every account.",
/// "type": "boolean"
/// }
/// },
/// "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>,
///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.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[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.
///
/// <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 {
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(
"{\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 \"Queue\": {\n \"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.\",\n \"enum\": [\n \"receive\",\n \"send\"\n ],\n \"title\": \"Queue\",\n \"type\": \"string\"\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/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/list/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 \"nextCursor\": {\n \"description\": \"Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"queues\": {\n \"items\": {\n \"$ref\": \"#/$defs/QueueSummary\"\n },\n \"type\": \"array\"\n },\n \"snapshotAt\": {\n \"description\": \"When the ranking was computed. A mediator MAY serve the ranking from a periodic survey rather than a live scan.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"truncated\": {\n \"description\": \"The ranking did not cover every account.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"queues\",\n \"snapshotAt\"\n ],\n \"title\": \"Messaging — List Queues — 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/list/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"properties\": {\n \"cursor\": {\n \"description\": \"Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"limit\": {\n \"description\": \"Maximum accounts per page. The mediator chooses a default when omitted.\",\n \"maximum\": 500,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"minCount\": {\n \"description\": \"Omit accounts whose ranked queue holds fewer messages than this. Default 1 (skip empty queues).\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"queue\": {\n \"$ref\": \"#/$defs/Queue\",\n \"description\": \"Which queue to rank by. Default `receive`.\"\n },\n \"sort\": {\n \"description\": \"Ranking key, descending. Default `count`.\",\n \"enum\": [\n \"count\",\n \"bytes\",\n \"oldest\",\n \"saturation\"\n ],\n \"type\": \"string\"\n }\n },\n \"title\": \"Messaging — List Queues — payload\",\n \"type\": \"object\"\n}\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(
"{\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 \"Queue\": {\n \"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.\",\n \"enum\": [\n \"receive\",\n \"send\"\n ],\n \"title\": \"Queue\",\n \"type\": \"string\"\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/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/queue/list/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 \"nextCursor\": {\n \"description\": \"Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"queues\": {\n \"items\": {\n \"$ref\": \"#/$defs/QueueSummary\"\n },\n \"type\": \"array\"\n },\n \"snapshotAt\": {\n \"description\": \"When the ranking was computed. A mediator MAY serve the ranking from a periodic survey rather than a live scan.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"truncated\": {\n \"description\": \"The ranking did not cover every account.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"queues\",\n \"snapshotAt\"\n ],\n \"title\": \"Messaging — List Queues — 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] = &[];
#[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:7d2e5a90-1c3b-4f6e-8a2d-4b9c0e1f2a01\",\n \"type\": \"https://trusttasks.org/spec/messaging/queue/list/0.1\",\n \"issuer\": \"did:web:admin.example\",\n \"recipient\": \"did:web:mediator.example\",\n \"issuedAt\": \"2026-09-21T10:05:00Z\",\n \"payload\": {\n \"queue\": \"send\",\n \"sort\": \"saturation\",\n \"limit\": 10\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:web:admin.example#key-1\",\n \"created\": \"2026-09-21T10:05:00Z\",\n \"proofPurpose\": \"assertionMethod\",\n \"proofValue\": \"z2Lm...\"\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:7d2e5a90-1c3b-4f6e-8a2d-4b9c0e1f2a02\",\n \"type\": \"https://trusttasks.org/spec/messaging/queue/list/0.1#response\",\n \"threadId\": \"urn:uuid:7d2e5a90-1c3b-4f6e-8a2d-4b9c0e1f2a01\",\n \"issuer\": \"did:web:mediator.example\",\n \"recipient\": \"did:web:admin.example\",\n \"issuedAt\": \"2026-09-21T10:05:00Z\",\n \"payload\": {\n \"queues\": [\n {\n \"did\": \"did:web:alice.example\",\n \"accountType\": \"standard\",\n \"receive\": { \"count\": 2, \"bytes\": 4810, \"limit\": 1000, \"saturation\": 0.002 },\n \"send\": { \"count\": 931, \"bytes\": 1804412, \"limit\": 1000, \"saturation\": 0.931, \"oldestAgeSeconds\": 86112, \"deliveredUnacked\": 931 }\n }\n ],\n \"snapshotAt\": \"2026-09-21T10:04:12Z\",\n \"truncated\": false,\n \"nextCursor\": \"c2F0OjAuOTMxOmFsaWNl\"\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");
}
}