//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/message/get`. 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/get/0.1",
/// "title": "Payload",
/// "type": "object",
/// "required": [
/// "msgId"
/// ],
/// "properties": {
/// "did": {
/// "description": "The account whose queue holds the message. 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"
/// },
/// "msgId": {
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The account whose queue holds the message. 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>,
#[serde(rename = "msgId")]
pub msg_id: PayloadMsgId,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///`PayloadMsgId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadMsgId(::std::string::String);
impl ::std::ops::Deref for PayloadMsgId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadMsgId> for ::std::string::String {
fn from(value: PayloadMsgId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadMsgId {
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 PayloadMsgId {
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 PayloadMsgId {
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 PayloadMsgId {
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 PayloadMsgId {
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/get request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/get/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The success response to a messaging/message/get request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/get/0.1#response.",
/// "type": "object",
/// "required": [
/// "message",
/// "meta"
/// ],
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "message": {
/// "description": "The stored message exactly as the mediator holds it — a DIDComm JWE/JWS as JSON text, a TSP message as CESR qb64 text. The mediator does not decrypt it. Bounded at 10 MiB; a stored message larger than that is refused with messageTooLarge rather than truncated.",
/// "type": "string",
/// "maxLength": 10485760
/// },
/// "meta": {
/// "$ref": "#/definitions/MessageMeta"
/// }
/// },
/// "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 stored message exactly as the mediator holds it — a DIDComm JWE/JWS as JSON text, a TSP message as CESR qb64 text. The mediator does not decrypt it. Bounded at 10 MiB; a stored message larger than that is refused with messageTooLarge rather than truncated.
pub message: ResponseMessage,
pub meta: MessageMeta,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///The stored message exactly as the mediator holds it — a DIDComm JWE/JWS as JSON text, a TSP message as CESR qb64 text. The mediator does not decrypt it. Bounded at 10 MiB; a stored message larger than that is refused with messageTooLarge rather than truncated.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The stored message exactly as the mediator holds it — a DIDComm JWE/JWS as JSON text, a TSP message as CESR qb64 text. The mediator does not decrypt it. Bounded at 10 MiB; a stored message larger than that is refused with messageTooLarge rather than truncated.",
/// "type": "string",
/// "maxLength": 10485760
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseMessage(::std::string::String);
impl ::std::ops::Deref for ResponseMessage {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseMessage> for ::std::string::String {
fn from(value: ResponseMessage) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseMessage {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 10485760usize {
return Err("longer than 10485760 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseMessage {
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 ResponseMessage {
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 ResponseMessage {
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 ResponseMessage {
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 {
did: ::std::result::Result<::std::option::Option<super::Vid>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
msg_id: ::std::result::Result<super::PayloadMsgId, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
did: Ok(Default::default()),
ext: Ok(Default::default()),
msg_id: Err("no value supplied for msg_id".to_string()),
}
}
}
impl Payload {
pub fn did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Vid>>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn msg_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadMsgId>,
T::Error: ::std::fmt::Display,
{
self.msg_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg_id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
did: value.did?,
ext: value.ext?,
msg_id: value.msg_id?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
did: Ok(value.did),
ext: Ok(value.ext),
msg_id: Ok(value.msg_id),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
message: ::std::result::Result<super::ResponseMessage, ::std::string::String>,
meta: ::std::result::Result<super::MessageMeta, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
message: Err("no value supplied for message".to_string()),
meta: Err("no value supplied for meta".to_string()),
}
}
}
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 message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseMessage>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| format!("error converting supplied value for message: {e}"));
self
}
pub fn meta<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MessageMeta>,
T::Error: ::std::fmt::Display,
{
self.meta = value
.try_into()
.map_err(|e| format!("error converting supplied value for meta: {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?,
message: value.message?,
meta: value.meta?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
message: Ok(value.message),
meta: Ok(value.meta),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/message/get/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/get request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/get/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 \"message\": {\n \"description\": \"The stored message exactly as the mediator holds it — a DIDComm JWE/JWS as JSON text, a TSP message as CESR qb64 text. The mediator does not decrypt it. Bounded at 10 MiB; a stored message larger than that is refused with messageTooLarge rather than truncated.\",\n \"maxLength\": 10485760,\n \"type\": \"string\"\n },\n \"meta\": {\n \"$ref\": \"#/$defs/MessageMeta\"\n }\n },\n \"required\": [\n \"meta\",\n \"message\"\n ],\n \"title\": \"Messaging — Get Message — 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/get/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"properties\": {\n \"did\": {\n \"$ref\": \"#/$defs/Vid\",\n \"description\": \"The account whose queue holds the message. 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 \"msgId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"msgId\"\n ],\n \"title\": \"Messaging — Get Message — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/message/get/0.1#response";
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/get request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/message/get/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 \"message\": {\n \"description\": \"The stored message exactly as the mediator holds it — a DIDComm JWE/JWS as JSON text, a TSP message as CESR qb64 text. The mediator does not decrypt it. Bounded at 10 MiB; a stored message larger than that is refused with messageTooLarge rather than truncated.\",\n \"maxLength\": 10485760,\n \"type\": \"string\"\n },\n \"meta\": {\n \"$ref\": \"#/$defs/MessageMeta\"\n }\n },\n \"required\": [\n \"meta\",\n \"message\"\n ],\n \"title\": \"Messaging — Get Message — 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,
error_codes::UNKNOWN_MESSAGE,
error_codes::ROOT_ADMIN_REQUIRED,
error_codes::MESSAGE_TOO_LARGE,
];
/// 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/get:unknownAccount`
///
/// The named account (`did`) has no account at this mediator.
///
/// Declared `retryable: false`.
pub const UNKNOWN_ACCOUNT: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "messaging/message/get:unknownAccount",
retryable: false,
};
/// `messaging/message/get:unknownMessage`
///
/// No message with this `msgId` is held in the named account's queues — it never existed, was deleted, or expired.
///
/// Declared `retryable: false`.
pub const UNKNOWN_MESSAGE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "messaging/message/get:unknownMessage",
retryable: false,
};
/// `messaging/message/get:rootAdminRequired`
///
/// The request names another account's message, and the requester is not a rootAdmin. An admin may see another account's message metadata through messaging/message/list, but not its body.
///
/// Declared `retryable: false`.
pub const ROOT_ADMIN_REQUIRED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "messaging/message/get:rootAdminRequired",
retryable: false,
};
/// `messaging/message/get:messageTooLarge`
///
/// The stored message exceeds the 10 MiB this task can carry. It is refused rather than truncated; it remains in the queue and can still be listed or deleted.
///
/// Declared `retryable: false`.
pub const MESSAGE_TOO_LARGE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "messaging/message/get:messageTooLarge",
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:7c1f0e52-3d0a-4b8e-9a51-2f1c6e7d9a01\",\n \"type\": \"https://trusttasks.org/spec/messaging/message/get/0.1\",\n \"issuer\": \"did:web:admin.example\",\n \"recipient\": \"did:web:mediator.example\",\n \"issuedAt\": \"2026-09-21T10:00:00Z\",\n \"payload\": {\n \"did\": \"did:web:alice.example\",\n \"msgId\": \"1726912345000-0\"\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:web:admin.example#key-1\",\n \"created\": \"2026-09-21T10:00:00Z\",\n \"proofPurpose\": \"assertionMethod\",\n \"proofValue\": \"z3kg...\"\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:7c1f0e52-3d0a-4b8e-9a51-2f1c6e7d9a02\",\n \"type\": \"https://trusttasks.org/spec/messaging/message/get/0.1#response\",\n \"threadId\": \"urn:uuid:7c1f0e52-3d0a-4b8e-9a51-2f1c6e7d9a01\",\n \"issuer\": \"did:web:mediator.example\",\n \"recipient\": \"did:web:admin.example\",\n \"issuedAt\": \"2026-09-21T10:00:01Z\",\n \"payload\": {\n \"meta\": {\n \"msgId\": \"1726912345000-0\",\n \"queue\": \"receive\",\n \"size\": 1843,\n \"receivedAt\": \"2026-09-21T09:12:25Z\",\n \"expiresAt\": \"2026-09-28T09:12:25Z\",\n \"to\": \"did:web:alice.example\",\n \"protocol\": \"didcomm\",\n \"deliveryState\": \"delivered\",\n \"deliveredAt\": \"2026-09-21T09:12:26Z\"\n },\n \"message\": \"{\\\"protected\\\":\\\"eyJ0eXAiOiJhcHBsaWNhdGlvbi9kaWRjb21tLWVuY3J5cHRlZCtqc29uIn0\\\",\\\"recipients\\\":[{\\\"header\\\":{\\\"kid\\\":\\\"did:web:alice.example#key-2\\\"},\\\"encrypted_key\\\":\\\"...\\\"}],\\\"iv\\\":\\\"...\\\",\\\"ciphertext\\\":\\\"...\\\",\\\"tag\\\":\\\"...\\\"}\"\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");
}
}