//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/message/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())
}
}
}
///`queued`: stored and not yet handed to the recipient. `delivered`: handed to the recipient (pickup or live stream) but not yet deleted by it — the recipient has not acknowledged it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DeliveryState",
/// "description": "`queued`: stored and not yet handed to the recipient. `delivered`: handed to the recipient (pickup or live stream) but not yet deleted by it — the recipient has not acknowledged it.",
/// "type": "string",
/// "enum": [
/// "queued",
/// "delivered"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum DeliveryState {
#[serde(rename = "queued")]
Queued,
#[serde(rename = "delivered")]
Delivered,
}
impl ::std::fmt::Display for DeliveryState {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Queued => f.write_str("queued"),
Self::Delivered => f.write_str("delivered"),
}
}
}
impl ::std::str::FromStr for DeliveryState {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"queued" => Ok(Self::Queued),
"delivered" => Ok(Self::Delivered),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for DeliveryState {
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 DeliveryState {
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 DeliveryState {
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())
})
}
}
///Metadata of one stored message. Never carries the message body.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "MessageMeta",
/// "description": "Metadata of one stored message. Never carries the message body.",
/// "type": "object",
/// "required": [
/// "msgId",
/// "queue",
/// "receivedAt",
/// "size"
/// ],
/// "properties": {
/// "deliveredAt": {
/// "description": "When the message was first handed to the recipient. Present only when deliveryState is `delivered`.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "deliveryState": {
/// "$ref": "#/definitions/DeliveryState"
/// },
/// "expiresAt": {
/// "description": "When the mediator will expire the message if it is not deleted first.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "from": {
/// "description": "The sender, where the mediator knows it. Absent for anonymous messages.",
/// "$ref": "#/definitions/Vid"
/// },
/// "msgId": {
/// "description": "The mediator's identifier for the stored message; the handle messaging/message/get and messaging/message/delete accept.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "protocol": {
/// "$ref": "#/definitions/WireProtocol"
/// },
/// "queue": {
/// "$ref": "#/definitions/Queue"
/// },
/// "receivedAt": {
/// "description": "When the mediator stored the message.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "size": {
/// "description": "Stored size in bytes.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "to": {
/// "description": "The recipient account.",
/// "$ref": "#/definitions/Vid"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct MessageMeta {
///When the message was first handed to the recipient. Present only when deliveryState is `delivered`.
#[serde(
rename = "deliveredAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub delivered_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
#[serde(
rename = "deliveryState",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub delivery_state: ::std::option::Option<DeliveryState>,
///When the mediator will expire the message if it is not deleted first.
#[serde(
rename = "expiresAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub expires_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///The sender, where the mediator knows it. Absent for anonymous messages.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub from: ::std::option::Option<Vid>,
///The mediator's identifier for the stored message; the handle messaging/message/get and messaging/message/delete accept.
#[serde(rename = "msgId")]
pub msg_id: MessageMetaMsgId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub protocol: ::std::option::Option<WireProtocol>,
pub queue: Queue,
///When the mediator stored the message.
#[serde(rename = "receivedAt")]
pub received_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Stored size in bytes.
pub size: u64,
///The recipient account.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub to: ::std::option::Option<Vid>,
}
impl MessageMeta {
pub fn builder() -> builder::MessageMeta {
Default::default()
}
}
///The mediator's identifier for the stored message; the handle messaging/message/get and messaging/message/delete accept.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The mediator's identifier for the stored message; the handle messaging/message/get and messaging/message/delete accept.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct MessageMetaMsgId(::std::string::String);
impl ::std::ops::Deref for MessageMetaMsgId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<MessageMetaMsgId> for ::std::string::String {
fn from(value: MessageMetaMsgId) -> Self {
value.0
}
}
impl ::std::str::FromStr for MessageMetaMsgId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for MessageMetaMsgId {
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 MessageMetaMsgId {
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 MessageMetaMsgId {
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 MessageMetaMsgId {
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/message/list/0.1",
/// "title": "Payload",
/// "type": "object",
/// "required": [
/// "queue"
/// ],
/// "properties": {
/// "cursor": {
/// "description": "Opaque continuation token from a prior page's nextCursor. Echoed verbatim; treated as unstructured by the requester.",
/// "type": "string",
/// "minLength": 1
/// },
/// "did": {
/// "description": "The account whose queue to list. Omitted = the requester's own account. A requester without administrative standing may name only itself.",
/// "$ref": "#/definitions/Vid"
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "limit": {
/// "description": "Maximum messages per page. The mediator chooses a default when omitted.",
/// "type": "integer",
/// "maximum": 500.0,
/// "minimum": 1.0
/// },
/// "peer": {
/// "description": "Only messages exchanged with this counterparty.",
/// "$ref": "#/definitions/Vid"
/// },
/// "queue": {
/// "$ref": "#/definitions/Queue"
/// }
/// },
/// "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>,
///The account whose queue to list. Omitted = the requester's own account. A requester without administrative standing may name only itself.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub did: ::std::option::Option<Vid>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Maximum messages 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>,
///Only messages exchanged with this counterparty.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub peer: ::std::option::Option<Vid>,
pub queue: Queue,
}
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())
})
}
}
///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 success response to a messaging/message/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/list/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The success response to a messaging/message/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/list/0.1#response.",
/// "type": "object",
/// "required": [
/// "messages"
/// ],
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "messages": {
/// "description": "The page, oldest first.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/MessageMeta"
/// }
/// },
/// "nextCursor": {
/// "description": "Opaque continuation token. Present only when further items remain beyond this page; omitted on the final page.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "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>,
///The page, oldest first.
pub messages: ::std::vec::Vec<MessageMeta>,
///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>,
}
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())
})
}
}
///The protocol a message travelled in, as the mediator detected it from the wire form. `didcomm` is DIDComm v2 (JWE/JWS); `didcommV1` is a DIDComm v1 envelope; `tsp` is a Trust Spanning Protocol message; `other` is anything the mediator could not classify.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "WireProtocol",
/// "description": "The protocol a message travelled in, as the mediator detected it from the wire form. `didcomm` is DIDComm v2 (JWE/JWS); `didcommV1` is a DIDComm v1 envelope; `tsp` is a Trust Spanning Protocol message; `other` is anything the mediator could not classify.",
/// "type": "string",
/// "enum": [
/// "didcomm",
/// "didcommV1",
/// "tsp",
/// "other"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum WireProtocol {
#[serde(rename = "didcomm")]
Didcomm,
#[serde(rename = "didcommV1")]
DidcommV1,
#[serde(rename = "tsp")]
Tsp,
#[serde(rename = "other")]
Other,
}
impl ::std::fmt::Display for WireProtocol {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Didcomm => f.write_str("didcomm"),
Self::DidcommV1 => f.write_str("didcommV1"),
Self::Tsp => f.write_str("tsp"),
Self::Other => f.write_str("other"),
}
}
}
impl ::std::str::FromStr for WireProtocol {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"didcomm" => Ok(Self::Didcomm),
"didcommV1" => Ok(Self::DidcommV1),
"tsp" => Ok(Self::Tsp),
"other" => Ok(Self::Other),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for WireProtocol {
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 WireProtocol {
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 WireProtocol {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct MessageMeta {
delivered_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
delivery_state: ::std::result::Result<
::std::option::Option<super::DeliveryState>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
from: ::std::result::Result<::std::option::Option<super::Vid>, ::std::string::String>,
msg_id: ::std::result::Result<super::MessageMetaMsgId, ::std::string::String>,
protocol: ::std::result::Result<
::std::option::Option<super::WireProtocol>,
::std::string::String,
>,
queue: ::std::result::Result<super::Queue, ::std::string::String>,
received_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
size: ::std::result::Result<u64, ::std::string::String>,
to: ::std::result::Result<::std::option::Option<super::Vid>, ::std::string::String>,
}
impl ::std::default::Default for MessageMeta {
fn default() -> Self {
Self {
delivered_at: Ok(Default::default()),
delivery_state: Ok(Default::default()),
expires_at: Ok(Default::default()),
from: Ok(Default::default()),
msg_id: Err("no value supplied for msg_id".to_string()),
protocol: Ok(Default::default()),
queue: Err("no value supplied for queue".to_string()),
received_at: Err("no value supplied for received_at".to_string()),
size: Err("no value supplied for size".to_string()),
to: Ok(Default::default()),
}
}
}
impl MessageMeta {
pub fn delivered_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.delivered_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for delivered_at: {e}"));
self
}
pub fn delivery_state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::DeliveryState>>,
T::Error: ::std::fmt::Display,
{
self.delivery_state = value
.try_into()
.map_err(|e| format!("error converting supplied value for delivery_state: {e}"));
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
pub fn from<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Vid>>,
T::Error: ::std::fmt::Display,
{
self.from = value
.try_into()
.map_err(|e| format!("error converting supplied value for from: {e}"));
self
}
pub fn msg_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MessageMetaMsgId>,
T::Error: ::std::fmt::Display,
{
self.msg_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg_id: {e}"));
self
}
pub fn protocol<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::WireProtocol>>,
T::Error: ::std::fmt::Display,
{
self.protocol = value
.try_into()
.map_err(|e| format!("error converting supplied value for protocol: {e}"));
self
}
pub fn queue<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<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 received_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.received_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for received_at: {e}"));
self
}
pub fn size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.size = value
.try_into()
.map_err(|e| format!("error converting supplied value for size: {e}"));
self
}
pub fn to<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Vid>>,
T::Error: ::std::fmt::Display,
{
self.to = value
.try_into()
.map_err(|e| format!("error converting supplied value for to: {e}"));
self
}
}
impl ::std::convert::TryFrom<MessageMeta> for super::MessageMeta {
type Error = super::error::ConversionError;
fn try_from(
value: MessageMeta,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
delivered_at: value.delivered_at?,
delivery_state: value.delivery_state?,
expires_at: value.expires_at?,
from: value.from?,
msg_id: value.msg_id?,
protocol: value.protocol?,
queue: value.queue?,
received_at: value.received_at?,
size: value.size?,
to: value.to?,
})
}
}
impl ::std::convert::From<super::MessageMeta> for MessageMeta {
fn from(value: super::MessageMeta) -> Self {
Self {
delivered_at: Ok(value.delivered_at),
delivery_state: Ok(value.delivery_state),
expires_at: Ok(value.expires_at),
from: Ok(value.from),
msg_id: Ok(value.msg_id),
protocol: Ok(value.protocol),
queue: Ok(value.queue),
received_at: Ok(value.received_at),
size: Ok(value.size),
to: Ok(value.to),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
cursor: ::std::result::Result<
::std::option::Option<super::PayloadCursor>,
::std::string::String,
>,
did: ::std::result::Result<::std::option::Option<super::Vid>, ::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,
>,
peer: ::std::result::Result<::std::option::Option<super::Vid>, ::std::string::String>,
queue: ::std::result::Result<super::Queue, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
cursor: Ok(Default::default()),
did: Ok(Default::default()),
ext: Ok(Default::default()),
limit: Ok(Default::default()),
peer: Ok(Default::default()),
queue: Err("no value supplied for queue".to_string()),
}
}
}
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 did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Vid>>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn 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 peer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Vid>>,
T::Error: ::std::fmt::Display,
{
self.peer = value
.try_into()
.map_err(|e| format!("error converting supplied value for peer: {e}"));
self
}
pub fn queue<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Queue>,
T::Error: ::std::fmt::Display,
{
self.queue = value
.try_into()
.map_err(|e| format!("error converting supplied value for queue: {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?,
did: value.did?,
ext: value.ext?,
limit: value.limit?,
peer: value.peer?,
queue: value.queue?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
cursor: Ok(value.cursor),
did: Ok(value.did),
ext: Ok(value.ext),
limit: Ok(value.limit),
peer: Ok(value.peer),
queue: Ok(value.queue),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
messages: ::std::result::Result<::std::vec::Vec<super::MessageMeta>, ::std::string::String>,
next_cursor: ::std::result::Result<
::std::option::Option<super::ResponseNextCursor>,
::std::string::String,
>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
messages: Err("no value supplied for messages".to_string()),
next_cursor: 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 messages<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::MessageMeta>>,
T::Error: ::std::fmt::Display,
{
self.messages = value
.try_into()
.map_err(|e| format!("error converting supplied value for messages: {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
}
}
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?,
messages: value.messages?,
next_cursor: value.next_cursor?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
messages: Ok(value.messages),
next_cursor: Ok(value.next_cursor),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/message/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 \"DeliveryState\": {\n \"description\": \"`queued`: stored and not yet handed to the recipient. `delivered`: handed to the recipient (pickup or live stream) but not yet deleted by it — the recipient has not acknowledged it.\",\n \"enum\": [\n \"queued\",\n \"delivered\"\n ],\n \"title\": \"DeliveryState\",\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 \"MessageMeta\": {\n \"additionalProperties\": false,\n \"description\": \"Metadata of one stored message. Never carries the message body.\",\n \"properties\": {\n \"deliveredAt\": {\n \"description\": \"When the message was first handed to the recipient. Present only when deliveryState is `delivered`.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"deliveryState\": {\n \"$ref\": \"#/$defs/DeliveryState\"\n },\n \"expiresAt\": {\n \"description\": \"When the mediator will expire the message if it is not deleted first.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"from\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The sender, where the mediator knows it. Absent for anonymous messages.\"\n },\n \"msgId\": {\n \"description\": \"The mediator's identifier for the stored message; the handle messaging/message/get and messaging/message/delete accept.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"protocol\": {\n \"$ref\": \"#/$defs/WireProtocol\"\n },\n \"queue\": {\n \"$ref\": \"#/$defs/Queue\"\n },\n \"receivedAt\": {\n \"description\": \"When the mediator stored the message.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"size\": {\n \"description\": \"Stored size in bytes.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The recipient account.\"\n }\n },\n \"required\": [\n \"msgId\",\n \"queue\",\n \"size\",\n \"receivedAt\"\n ],\n \"title\": \"MessageMeta\",\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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a messaging/message/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/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 \"messages\": {\n \"description\": \"The page, oldest first.\",\n \"items\": {\n \"$ref\": \"#/$defs/MessageMeta\"\n },\n \"type\": \"array\"\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 },\n \"required\": [\n \"messages\"\n ],\n \"title\": \"Messaging — List Messages — 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 \"WireProtocol\": {\n \"description\": \"The protocol a message travelled in, as the mediator detected it from the wire form. `didcomm` is DIDComm v2 (JWE/JWS); `didcommV1` is a DIDComm v1 envelope; `tsp` is a Trust Spanning Protocol message; `other` is anything the mediator could not classify.\",\n \"enum\": [\n \"didcomm\",\n \"didcommV1\",\n \"tsp\",\n \"other\"\n ],\n \"title\": \"WireProtocol\",\n \"type\": \"string\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/messaging/message/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 \"did\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The account whose queue to list. Omitted = the requester's own account. A requester without administrative standing may name only itself.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"limit\": {\n \"description\": \"Maximum messages per page. The mediator chooses a default when omitted.\",\n \"maximum\": 500,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"peer\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"Only messages exchanged with this counterparty.\"\n },\n \"queue\": {\n \"$ref\": \"#/$defs/Queue\"\n }\n },\n \"required\": [\n \"queue\"\n ],\n \"title\": \"Messaging — List Messages — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/messaging/message/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 \"DeliveryState\": {\n \"description\": \"`queued`: stored and not yet handed to the recipient. `delivered`: handed to the recipient (pickup or live stream) but not yet deleted by it — the recipient has not acknowledged it.\",\n \"enum\": [\n \"queued\",\n \"delivered\"\n ],\n \"title\": \"DeliveryState\",\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 \"MessageMeta\": {\n \"additionalProperties\": false,\n \"description\": \"Metadata of one stored message. Never carries the message body.\",\n \"properties\": {\n \"deliveredAt\": {\n \"description\": \"When the message was first handed to the recipient. Present only when deliveryState is `delivered`.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"deliveryState\": {\n \"$ref\": \"#/$defs/DeliveryState\"\n },\n \"expiresAt\": {\n \"description\": \"When the mediator will expire the message if it is not deleted first.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"from\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The sender, where the mediator knows it. Absent for anonymous messages.\"\n },\n \"msgId\": {\n \"description\": \"The mediator's identifier for the stored message; the handle messaging/message/get and messaging/message/delete accept.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"protocol\": {\n \"$ref\": \"#/$defs/WireProtocol\"\n },\n \"queue\": {\n \"$ref\": \"#/$defs/Queue\"\n },\n \"receivedAt\": {\n \"description\": \"When the mediator stored the message.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"size\": {\n \"description\": \"Stored size in bytes.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The recipient account.\"\n }\n },\n \"required\": [\n \"msgId\",\n \"queue\",\n \"size\",\n \"receivedAt\"\n ],\n \"title\": \"MessageMeta\",\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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a messaging/message/list request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/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 \"messages\": {\n \"description\": \"The page, oldest first.\",\n \"items\": {\n \"$ref\": \"#/$defs/MessageMeta\"\n },\n \"type\": \"array\"\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 },\n \"required\": [\n \"messages\"\n ],\n \"title\": \"Messaging — List Messages — 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 \"WireProtocol\": {\n \"description\": \"The protocol a message travelled in, as the mediator detected it from the wire form. `didcomm` is DIDComm v2 (JWE/JWS); `didcommV1` is a DIDComm v1 envelope; `tsp` is a Trust Spanning Protocol message; `other` is anything the mediator could not classify.\",\n \"enum\": [\n \"didcomm\",\n \"didcommV1\",\n \"tsp\",\n \"other\"\n ],\n \"title\": \"WireProtocol\",\n \"type\": \"string\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[error_codes::UNKNOWN_ACCOUNT];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `messaging/message/list:unknownAccount`
///
/// The named account does not exist at this mediator.
///
/// Declared `retryable: false`.
pub const UNKNOWN_ACCOUNT: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "messaging/message/list:unknownAccount",
retryable: false,
};
}
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
#[test]
fn request_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:e5b2d9c0-8a1f-4e37-a6d4-1c9f3b7e2a01\",\n \"type\": \"https://trusttasks.org/spec/messaging/message/list/0.1\",\n \"issuer\": \"did:web:alice.example\",\n \"recipient\": \"did:web:mediator.example\",\n \"issuedAt\": \"2026-09-21T10:12:00Z\",\n \"payload\": {\n \"queue\": \"send\",\n \"peer\": \"did:web:carol.example\",\n \"limit\": 2\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:web:alice.example#key-1\",\n \"created\": \"2026-09-21T10:12:00Z\",\n \"proofPurpose\": \"assertionMethod\",\n \"proofValue\": \"z4Hn...\"\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:e5b2d9c0-8a1f-4e37-a6d4-1c9f3b7e2a02\",\n \"type\": \"https://trusttasks.org/spec/messaging/message/list/0.1#response\",\n \"threadId\": \"urn:uuid:e5b2d9c0-8a1f-4e37-a6d4-1c9f3b7e2a01\",\n \"issuer\": \"did:web:mediator.example\",\n \"recipient\": \"did:web:alice.example\",\n \"issuedAt\": \"2026-09-21T10:12:00Z\",\n \"payload\": {\n \"messages\": [\n {\n \"msgId\": \"1758362400123-0\",\n \"queue\": \"send\",\n \"size\": 1931,\n \"receivedAt\": \"2026-09-20T10:05:12Z\",\n \"expiresAt\": \"2026-09-27T10:05:12Z\",\n \"from\": \"did:web:alice.example\",\n \"to\": \"did:web:carol.example\",\n \"protocol\": \"didcomm\",\n \"deliveryState\": \"delivered\",\n \"deliveredAt\": \"2026-09-20T10:05:13Z\"\n },\n {\n \"msgId\": \"1758362417840-0\",\n \"queue\": \"send\",\n \"size\": 1944,\n \"receivedAt\": \"2026-09-20T10:05:29Z\",\n \"expiresAt\": \"2026-09-27T10:05:29Z\",\n \"from\": \"did:web:alice.example\",\n \"to\": \"did:web:carol.example\",\n \"protocol\": \"tsp\",\n \"deliveryState\": \"delivered\",\n \"deliveredAt\": \"2026-09-20T10:05:30Z\"\n }\n ],\n \"nextCursor\": \"MTc1ODM2MjQxNzg0MC0w\"\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");
}
}