//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `messaging/stats/show`. 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())
}
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Payload`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/messaging/stats/show/0.1",
/// "title": "Payload",
/// "type": "object",
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///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>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The depth of one queue and its effective limit.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QueueDepth",
/// "description": "The depth of one queue and its effective limit.",
/// "type": "object",
/// "required": [
/// "bytes",
/// "count"
/// ],
/// "properties": {
/// "bytes": {
/// "description": "Total stored size of those messages, in bytes.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "count": {
/// "description": "Messages currently in the queue.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "deliveredUnacked": {
/// "description": "Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "limit": {
/// "description": "The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.",
/// "type": "integer",
/// "minimum": -1.0
/// },
/// "oldestAgeSeconds": {
/// "description": "Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "saturation": {
/// "description": "count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.",
/// "type": "number",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QueueDepth {
///Total stored size of those messages, in bytes.
pub bytes: u64,
///Messages currently in the queue.
pub count: u64,
///Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.
#[serde(
rename = "deliveredUnacked",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub delivered_unacked: ::std::option::Option<u64>,
///The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<i64>,
///Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.
#[serde(
rename = "oldestAgeSeconds",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub oldest_age_seconds: ::std::option::Option<u64>,
///count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub saturation: ::std::option::Option<f64>,
}
impl QueueDepth {
pub fn builder() -> builder::QueueDepth {
Default::default()
}
}
///The success response to a messaging/stats/show request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/stats/show/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The success response to a messaging/stats/show request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/stats/show/0.1#response.",
/// "type": "object",
/// "required": [
/// "connections",
/// "forwarding",
/// "totals",
/// "uptimeSeconds",
/// "version"
/// ],
/// "properties": {
/// "connections": {
/// "type": "object",
/// "required": [
/// "websocketActive"
/// ],
/// "properties": {
/// "websocketActive": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "websocketMax": {
/// "description": "Configured ceiling; absent when unlimited.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "forwarding": {
/// "type": "object",
/// "required": [
/// "queueLength"
/// ],
/// "properties": {
/// "circuitBreaker": {
/// "description": "State of the store circuit breaker. `open` means the mediator is shedding store operations.",
/// "type": "string",
/// "enum": [
/// "closed",
/// "open",
/// "halfOpen"
/// ]
/// },
/// "queueLength": {
/// "description": "Messages waiting to be forwarded to other mediators.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "queueLimit": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// },
/// "queues": {
/// "description": "Aggregate of the mediator's most recent queue survey. Absent when no survey has completed.",
/// "type": "object",
/// "required": [
/// "accounts",
/// "surveyedAt"
/// ],
/// "properties": {
/// "accounts": {
/// "description": "Accounts the survey covered.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "receive": {
/// "description": "Totals across every surveyed receive queue; `saturation` is the maximum of any single queue.",
/// "$ref": "#/definitions/QueueDepth"
/// },
/// "send": {
/// "description": "Totals across every surveyed send queue; `saturation` is the maximum of any single queue.",
/// "$ref": "#/definitions/QueueDepth"
/// },
/// "surveyedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "truncated": {
/// "description": "The survey stopped before covering every account.",
/// "type": "boolean"
/// }
/// },
/// "additionalProperties": false
/// },
/// "startedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "totals": {
/// "description": "Lifetime counters since the mediator's store was created. Monotonic; a client derives rates from successive readings.",
/// "type": "object",
/// "required": [
/// "deletedCount",
/// "receivedBytes",
/// "receivedCount",
/// "sentBytes",
/// "sentCount"
/// ],
/// "properties": {
/// "deletedBytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "deletedCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "invitationsClaimed": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "invitationsCreated": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "receivedBytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "receivedCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sentBytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sentCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sessionsAuthenticated": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sessionsCreated": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "websocketClosed": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "websocketOpened": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// },
/// "uptimeSeconds": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "version": {
/// "description": "The mediator software's version string.",
/// "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 {
pub connections: ResponseConnections,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub forwarding: ResponseForwarding,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub queues: ::std::option::Option<ResponseQueues>,
#[serde(
rename = "startedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub started_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
pub totals: ResponseTotals,
#[serde(rename = "uptimeSeconds")]
pub uptime_seconds: u64,
///The mediator software's version string.
pub version: ResponseVersion,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseConnections`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "websocketActive"
/// ],
/// "properties": {
/// "websocketActive": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "websocketMax": {
/// "description": "Configured ceiling; absent when unlimited.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseConnections {
#[serde(rename = "websocketActive")]
pub websocket_active: u64,
///Configured ceiling; absent when unlimited.
#[serde(
rename = "websocketMax",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub websocket_max: ::std::option::Option<u64>,
}
impl ResponseConnections {
pub fn builder() -> builder::ResponseConnections {
Default::default()
}
}
///`ResponseForwarding`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "queueLength"
/// ],
/// "properties": {
/// "circuitBreaker": {
/// "description": "State of the store circuit breaker. `open` means the mediator is shedding store operations.",
/// "type": "string",
/// "enum": [
/// "closed",
/// "open",
/// "halfOpen"
/// ]
/// },
/// "queueLength": {
/// "description": "Messages waiting to be forwarded to other mediators.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "queueLimit": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseForwarding {
///State of the store circuit breaker. `open` means the mediator is shedding store operations.
#[serde(
rename = "circuitBreaker",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub circuit_breaker: ::std::option::Option<ResponseForwardingCircuitBreaker>,
///Messages waiting to be forwarded to other mediators.
#[serde(rename = "queueLength")]
pub queue_length: u64,
#[serde(
rename = "queueLimit",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub queue_limit: ::std::option::Option<u64>,
}
impl ResponseForwarding {
pub fn builder() -> builder::ResponseForwarding {
Default::default()
}
}
///State of the store circuit breaker. `open` means the mediator is shedding store operations.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "State of the store circuit breaker. `open` means the mediator is shedding store operations.",
/// "type": "string",
/// "enum": [
/// "closed",
/// "open",
/// "halfOpen"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseForwardingCircuitBreaker {
#[serde(rename = "closed")]
Closed,
#[serde(rename = "open")]
Open,
#[serde(rename = "halfOpen")]
HalfOpen,
}
impl ::std::fmt::Display for ResponseForwardingCircuitBreaker {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Closed => f.write_str("closed"),
Self::Open => f.write_str("open"),
Self::HalfOpen => f.write_str("halfOpen"),
}
}
}
impl ::std::str::FromStr for ResponseForwardingCircuitBreaker {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"closed" => Ok(Self::Closed),
"open" => Ok(Self::Open),
"halfOpen" => Ok(Self::HalfOpen),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseForwardingCircuitBreaker {
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 ResponseForwardingCircuitBreaker {
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 ResponseForwardingCircuitBreaker {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Aggregate of the mediator's most recent queue survey. Absent when no survey has completed.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Aggregate of the mediator's most recent queue survey. Absent when no survey has completed.",
/// "type": "object",
/// "required": [
/// "accounts",
/// "surveyedAt"
/// ],
/// "properties": {
/// "accounts": {
/// "description": "Accounts the survey covered.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "receive": {
/// "description": "Totals across every surveyed receive queue; `saturation` is the maximum of any single queue.",
/// "$ref": "#/definitions/QueueDepth"
/// },
/// "send": {
/// "description": "Totals across every surveyed send queue; `saturation` is the maximum of any single queue.",
/// "$ref": "#/definitions/QueueDepth"
/// },
/// "surveyedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "truncated": {
/// "description": "The survey stopped before covering every account.",
/// "type": "boolean"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseQueues {
///Accounts the survey covered.
pub accounts: u64,
///Totals across every surveyed receive queue; `saturation` is the maximum of any single queue.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub receive: ::std::option::Option<QueueDepth>,
///Totals across every surveyed send queue; `saturation` is the maximum of any single queue.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub send: ::std::option::Option<QueueDepth>,
#[serde(rename = "surveyedAt")]
pub surveyed_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The survey stopped before covering every account.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub truncated: ::std::option::Option<bool>,
}
impl ResponseQueues {
pub fn builder() -> builder::ResponseQueues {
Default::default()
}
}
///Lifetime counters since the mediator's store was created. Monotonic; a client derives rates from successive readings.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Lifetime counters since the mediator's store was created. Monotonic; a client derives rates from successive readings.",
/// "type": "object",
/// "required": [
/// "deletedCount",
/// "receivedBytes",
/// "receivedCount",
/// "sentBytes",
/// "sentCount"
/// ],
/// "properties": {
/// "deletedBytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "deletedCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "invitationsClaimed": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "invitationsCreated": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "receivedBytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "receivedCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sentBytes": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sentCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sessionsAuthenticated": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sessionsCreated": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "websocketClosed": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "websocketOpened": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseTotals {
#[serde(
rename = "deletedBytes",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub deleted_bytes: ::std::option::Option<u64>,
#[serde(rename = "deletedCount")]
pub deleted_count: u64,
#[serde(
rename = "invitationsClaimed",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub invitations_claimed: ::std::option::Option<u64>,
#[serde(
rename = "invitationsCreated",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub invitations_created: ::std::option::Option<u64>,
#[serde(rename = "receivedBytes")]
pub received_bytes: u64,
#[serde(rename = "receivedCount")]
pub received_count: u64,
#[serde(rename = "sentBytes")]
pub sent_bytes: u64,
#[serde(rename = "sentCount")]
pub sent_count: u64,
#[serde(
rename = "sessionsAuthenticated",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub sessions_authenticated: ::std::option::Option<u64>,
#[serde(
rename = "sessionsCreated",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub sessions_created: ::std::option::Option<u64>,
#[serde(
rename = "websocketClosed",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub websocket_closed: ::std::option::Option<u64>,
#[serde(
rename = "websocketOpened",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub websocket_opened: ::std::option::Option<u64>,
}
impl ResponseTotals {
pub fn builder() -> builder::ResponseTotals {
Default::default()
}
}
///The mediator software's version string.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The mediator software's version string.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseVersion(::std::string::String);
impl ::std::ops::Deref for ResponseVersion {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseVersion> for ::std::string::String {
fn from(value: ResponseVersion) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseVersion {
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 ResponseVersion {
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 ResponseVersion {
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 ResponseVersion {
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 ResponseVersion {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
}
}
}
impl Payload {
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
}
}
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 { ext: value.ext? })
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self { ext: Ok(value.ext) }
}
}
#[derive(Clone, Debug)]
pub struct QueueDepth {
bytes: ::std::result::Result<u64, ::std::string::String>,
count: ::std::result::Result<u64, ::std::string::String>,
delivered_unacked: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
limit: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
oldest_age_seconds:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
saturation: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
}
impl ::std::default::Default for QueueDepth {
fn default() -> Self {
Self {
bytes: Err("no value supplied for bytes".to_string()),
count: Err("no value supplied for count".to_string()),
delivered_unacked: Ok(Default::default()),
limit: Ok(Default::default()),
oldest_age_seconds: Ok(Default::default()),
saturation: Ok(Default::default()),
}
}
}
impl QueueDepth {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.count = value
.try_into()
.map_err(|e| format!("error converting supplied value for count: {e}"));
self
}
pub fn delivered_unacked<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.delivered_unacked = value
.try_into()
.map_err(|e| format!("error converting supplied value for delivered_unacked: {e}"));
self
}
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn oldest_age_seconds<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.oldest_age_seconds = value.try_into().map_err(|e| {
format!("error converting supplied value for oldest_age_seconds: {e}")
});
self
}
pub fn saturation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.saturation = value
.try_into()
.map_err(|e| format!("error converting supplied value for saturation: {e}"));
self
}
}
impl ::std::convert::TryFrom<QueueDepth> for super::QueueDepth {
type Error = super::error::ConversionError;
fn try_from(
value: QueueDepth,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
count: value.count?,
delivered_unacked: value.delivered_unacked?,
limit: value.limit?,
oldest_age_seconds: value.oldest_age_seconds?,
saturation: value.saturation?,
})
}
}
impl ::std::convert::From<super::QueueDepth> for QueueDepth {
fn from(value: super::QueueDepth) -> Self {
Self {
bytes: Ok(value.bytes),
count: Ok(value.count),
delivered_unacked: Ok(value.delivered_unacked),
limit: Ok(value.limit),
oldest_age_seconds: Ok(value.oldest_age_seconds),
saturation: Ok(value.saturation),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
connections: ::std::result::Result<super::ResponseConnections, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
forwarding: ::std::result::Result<super::ResponseForwarding, ::std::string::String>,
queues: ::std::result::Result<
::std::option::Option<super::ResponseQueues>,
::std::string::String,
>,
started_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
totals: ::std::result::Result<super::ResponseTotals, ::std::string::String>,
uptime_seconds: ::std::result::Result<u64, ::std::string::String>,
version: ::std::result::Result<super::ResponseVersion, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
connections: Err("no value supplied for connections".to_string()),
ext: Ok(Default::default()),
forwarding: Err("no value supplied for forwarding".to_string()),
queues: Ok(Default::default()),
started_at: Ok(Default::default()),
totals: Err("no value supplied for totals".to_string()),
uptime_seconds: Err("no value supplied for uptime_seconds".to_string()),
version: Err("no value supplied for version".to_string()),
}
}
}
impl Response {
pub fn connections<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseConnections>,
T::Error: ::std::fmt::Display,
{
self.connections = value
.try_into()
.map_err(|e| format!("error converting supplied value for connections: {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 forwarding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseForwarding>,
T::Error: ::std::fmt::Display,
{
self.forwarding = value
.try_into()
.map_err(|e| format!("error converting supplied value for forwarding: {e}"));
self
}
pub fn queues<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseQueues>>,
T::Error: ::std::fmt::Display,
{
self.queues = value
.try_into()
.map_err(|e| format!("error converting supplied value for queues: {e}"));
self
}
pub fn started_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.started_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for started_at: {e}"));
self
}
pub fn totals<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseTotals>,
T::Error: ::std::fmt::Display,
{
self.totals = value
.try_into()
.map_err(|e| format!("error converting supplied value for totals: {e}"));
self
}
pub fn uptime_seconds<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.uptime_seconds = value
.try_into()
.map_err(|e| format!("error converting supplied value for uptime_seconds: {e}"));
self
}
pub fn version<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseVersion>,
T::Error: ::std::fmt::Display,
{
self.version = value
.try_into()
.map_err(|e| format!("error converting supplied value for version: {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 {
connections: value.connections?,
ext: value.ext?,
forwarding: value.forwarding?,
queues: value.queues?,
started_at: value.started_at?,
totals: value.totals?,
uptime_seconds: value.uptime_seconds?,
version: value.version?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
connections: Ok(value.connections),
ext: Ok(value.ext),
forwarding: Ok(value.forwarding),
queues: Ok(value.queues),
started_at: Ok(value.started_at),
totals: Ok(value.totals),
uptime_seconds: Ok(value.uptime_seconds),
version: Ok(value.version),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseConnections {
websocket_active: ::std::result::Result<u64, ::std::string::String>,
websocket_max: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for ResponseConnections {
fn default() -> Self {
Self {
websocket_active: Err("no value supplied for websocket_active".to_string()),
websocket_max: Ok(Default::default()),
}
}
}
impl ResponseConnections {
pub fn websocket_active<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.websocket_active = value
.try_into()
.map_err(|e| format!("error converting supplied value for websocket_active: {e}"));
self
}
pub fn websocket_max<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.websocket_max = value
.try_into()
.map_err(|e| format!("error converting supplied value for websocket_max: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseConnections> for super::ResponseConnections {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseConnections,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
websocket_active: value.websocket_active?,
websocket_max: value.websocket_max?,
})
}
}
impl ::std::convert::From<super::ResponseConnections> for ResponseConnections {
fn from(value: super::ResponseConnections) -> Self {
Self {
websocket_active: Ok(value.websocket_active),
websocket_max: Ok(value.websocket_max),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseForwarding {
circuit_breaker: ::std::result::Result<
::std::option::Option<super::ResponseForwardingCircuitBreaker>,
::std::string::String,
>,
queue_length: ::std::result::Result<u64, ::std::string::String>,
queue_limit: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for ResponseForwarding {
fn default() -> Self {
Self {
circuit_breaker: Ok(Default::default()),
queue_length: Err("no value supplied for queue_length".to_string()),
queue_limit: Ok(Default::default()),
}
}
}
impl ResponseForwarding {
pub fn circuit_breaker<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::ResponseForwardingCircuitBreaker>,
>,
T::Error: ::std::fmt::Display,
{
self.circuit_breaker = value
.try_into()
.map_err(|e| format!("error converting supplied value for circuit_breaker: {e}"));
self
}
pub fn queue_length<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.queue_length = value
.try_into()
.map_err(|e| format!("error converting supplied value for queue_length: {e}"));
self
}
pub fn queue_limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.queue_limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for queue_limit: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseForwarding> for super::ResponseForwarding {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseForwarding,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
circuit_breaker: value.circuit_breaker?,
queue_length: value.queue_length?,
queue_limit: value.queue_limit?,
})
}
}
impl ::std::convert::From<super::ResponseForwarding> for ResponseForwarding {
fn from(value: super::ResponseForwarding) -> Self {
Self {
circuit_breaker: Ok(value.circuit_breaker),
queue_length: Ok(value.queue_length),
queue_limit: Ok(value.queue_limit),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseQueues {
accounts: ::std::result::Result<u64, ::std::string::String>,
receive:
::std::result::Result<::std::option::Option<super::QueueDepth>, ::std::string::String>,
send:
::std::result::Result<::std::option::Option<super::QueueDepth>, ::std::string::String>,
surveyed_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
truncated: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
}
impl ::std::default::Default for ResponseQueues {
fn default() -> Self {
Self {
accounts: Err("no value supplied for accounts".to_string()),
receive: Ok(Default::default()),
send: Ok(Default::default()),
surveyed_at: Err("no value supplied for surveyed_at".to_string()),
truncated: Ok(Default::default()),
}
}
}
impl ResponseQueues {
pub fn accounts<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.accounts = value
.try_into()
.map_err(|e| format!("error converting supplied value for accounts: {e}"));
self
}
pub fn receive<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::QueueDepth>>,
T::Error: ::std::fmt::Display,
{
self.receive = value
.try_into()
.map_err(|e| format!("error converting supplied value for receive: {e}"));
self
}
pub fn send<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::QueueDepth>>,
T::Error: ::std::fmt::Display,
{
self.send = value
.try_into()
.map_err(|e| format!("error converting supplied value for send: {e}"));
self
}
pub fn surveyed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.surveyed_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for surveyed_at: {e}"));
self
}
pub fn truncated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.truncated = value
.try_into()
.map_err(|e| format!("error converting supplied value for truncated: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseQueues> for super::ResponseQueues {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseQueues,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
accounts: value.accounts?,
receive: value.receive?,
send: value.send?,
surveyed_at: value.surveyed_at?,
truncated: value.truncated?,
})
}
}
impl ::std::convert::From<super::ResponseQueues> for ResponseQueues {
fn from(value: super::ResponseQueues) -> Self {
Self {
accounts: Ok(value.accounts),
receive: Ok(value.receive),
send: Ok(value.send),
surveyed_at: Ok(value.surveyed_at),
truncated: Ok(value.truncated),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseTotals {
deleted_bytes: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
deleted_count: ::std::result::Result<u64, ::std::string::String>,
invitations_claimed:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
invitations_created:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
received_bytes: ::std::result::Result<u64, ::std::string::String>,
received_count: ::std::result::Result<u64, ::std::string::String>,
sent_bytes: ::std::result::Result<u64, ::std::string::String>,
sent_count: ::std::result::Result<u64, ::std::string::String>,
sessions_authenticated:
::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
sessions_created: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
websocket_closed: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
websocket_opened: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for ResponseTotals {
fn default() -> Self {
Self {
deleted_bytes: Ok(Default::default()),
deleted_count: Err("no value supplied for deleted_count".to_string()),
invitations_claimed: Ok(Default::default()),
invitations_created: Ok(Default::default()),
received_bytes: Err("no value supplied for received_bytes".to_string()),
received_count: Err("no value supplied for received_count".to_string()),
sent_bytes: Err("no value supplied for sent_bytes".to_string()),
sent_count: Err("no value supplied for sent_count".to_string()),
sessions_authenticated: Ok(Default::default()),
sessions_created: Ok(Default::default()),
websocket_closed: Ok(Default::default()),
websocket_opened: Ok(Default::default()),
}
}
}
impl ResponseTotals {
pub fn deleted_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.deleted_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for deleted_bytes: {e}"));
self
}
pub fn deleted_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.deleted_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for deleted_count: {e}"));
self
}
pub fn invitations_claimed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.invitations_claimed = value.try_into().map_err(|e| {
format!("error converting supplied value for invitations_claimed: {e}")
});
self
}
pub fn invitations_created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.invitations_created = value.try_into().map_err(|e| {
format!("error converting supplied value for invitations_created: {e}")
});
self
}
pub fn received_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.received_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for received_bytes: {e}"));
self
}
pub fn received_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.received_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for received_count: {e}"));
self
}
pub fn sent_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.sent_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for sent_bytes: {e}"));
self
}
pub fn sent_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.sent_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for sent_count: {e}"));
self
}
pub fn sessions_authenticated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.sessions_authenticated = value.try_into().map_err(|e| {
format!("error converting supplied value for sessions_authenticated: {e}")
});
self
}
pub fn sessions_created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.sessions_created = value
.try_into()
.map_err(|e| format!("error converting supplied value for sessions_created: {e}"));
self
}
pub fn websocket_closed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.websocket_closed = value
.try_into()
.map_err(|e| format!("error converting supplied value for websocket_closed: {e}"));
self
}
pub fn websocket_opened<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.websocket_opened = value
.try_into()
.map_err(|e| format!("error converting supplied value for websocket_opened: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseTotals> for super::ResponseTotals {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseTotals,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
deleted_bytes: value.deleted_bytes?,
deleted_count: value.deleted_count?,
invitations_claimed: value.invitations_claimed?,
invitations_created: value.invitations_created?,
received_bytes: value.received_bytes?,
received_count: value.received_count?,
sent_bytes: value.sent_bytes?,
sent_count: value.sent_count?,
sessions_authenticated: value.sessions_authenticated?,
sessions_created: value.sessions_created?,
websocket_closed: value.websocket_closed?,
websocket_opened: value.websocket_opened?,
})
}
}
impl ::std::convert::From<super::ResponseTotals> for ResponseTotals {
fn from(value: super::ResponseTotals) -> Self {
Self {
deleted_bytes: Ok(value.deleted_bytes),
deleted_count: Ok(value.deleted_count),
invitations_claimed: Ok(value.invitations_claimed),
invitations_created: Ok(value.invitations_created),
received_bytes: Ok(value.received_bytes),
received_count: Ok(value.received_count),
sent_bytes: Ok(value.sent_bytes),
sent_count: Ok(value.sent_count),
sessions_authenticated: Ok(value.sessions_authenticated),
sessions_created: Ok(value.sessions_created),
websocket_closed: Ok(value.websocket_closed),
websocket_opened: Ok(value.websocket_opened),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/stats/show/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 \"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 \"QueueDepth\": {\n \"additionalProperties\": false,\n \"description\": \"The depth of one queue and its effective limit.\",\n \"properties\": {\n \"bytes\": {\n \"description\": \"Total stored size of those messages, in bytes.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"count\": {\n \"description\": \"Messages currently in the queue.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"deliveredUnacked\": {\n \"description\": \"Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"limit\": {\n \"description\": \"The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.\",\n \"minimum\": -1,\n \"type\": \"integer\"\n },\n \"oldestAgeSeconds\": {\n \"description\": \"Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"saturation\": {\n \"description\": \"count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.\",\n \"minimum\": 0,\n \"type\": \"number\"\n }\n },\n \"required\": [\n \"count\",\n \"bytes\"\n ],\n \"title\": \"QueueDepth\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a messaging/stats/show request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/stats/show/0.1#response.\",\n \"properties\": {\n \"connections\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"websocketActive\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"websocketMax\": {\n \"description\": \"Configured ceiling; absent when unlimited.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"websocketActive\"\n ],\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"forwarding\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"circuitBreaker\": {\n \"description\": \"State of the store circuit breaker. `open` means the mediator is shedding store operations.\",\n \"enum\": [\n \"closed\",\n \"open\",\n \"halfOpen\"\n ],\n \"type\": \"string\"\n },\n \"queueLength\": {\n \"description\": \"Messages waiting to be forwarded to other mediators.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"queueLimit\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"queueLength\"\n ],\n \"type\": \"object\"\n },\n \"queues\": {\n \"additionalProperties\": false,\n \"description\": \"Aggregate of the mediator's most recent queue survey. Absent when no survey has completed.\",\n \"properties\": {\n \"accounts\": {\n \"description\": \"Accounts the survey covered.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"receive\": {\n \"$ref\": \"#/$defs/QueueDepth\",\n \"description\": \"Totals across every surveyed receive queue; `saturation` is the maximum of any single queue.\"\n },\n \"send\": {\n \"$ref\": \"#/$defs/QueueDepth\",\n \"description\": \"Totals across every surveyed send queue; `saturation` is the maximum of any single queue.\"\n },\n \"surveyedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"truncated\": {\n \"description\": \"The survey stopped before covering every account.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"surveyedAt\",\n \"accounts\"\n ],\n \"type\": \"object\"\n },\n \"startedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"totals\": {\n \"additionalProperties\": false,\n \"description\": \"Lifetime counters since the mediator's store was created. Monotonic; a client derives rates from successive readings.\",\n \"properties\": {\n \"deletedBytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"deletedCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"invitationsClaimed\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"invitationsCreated\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"receivedBytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"receivedCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sentBytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sentCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sessionsAuthenticated\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sessionsCreated\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"websocketClosed\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"websocketOpened\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"receivedCount\",\n \"receivedBytes\",\n \"sentCount\",\n \"sentBytes\",\n \"deletedCount\"\n ],\n \"type\": \"object\"\n },\n \"uptimeSeconds\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"version\": {\n \"description\": \"The mediator software's version string.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"version\",\n \"uptimeSeconds\",\n \"connections\",\n \"totals\",\n \"forwarding\"\n ],\n \"title\": \"Messaging — Show Mediator Statistics — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/messaging/stats/show/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n }\n },\n \"title\": \"Messaging — Show Mediator Statistics — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/messaging/stats/show/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 \"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 \"QueueDepth\": {\n \"additionalProperties\": false,\n \"description\": \"The depth of one queue and its effective limit.\",\n \"properties\": {\n \"bytes\": {\n \"description\": \"Total stored size of those messages, in bytes.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"count\": {\n \"description\": \"Messages currently in the queue.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"deliveredUnacked\": {\n \"description\": \"Messages in the queue whose state is `delivered` — handed out but not yet deleted by the recipient. Absent when the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"limit\": {\n \"description\": \"The effective message-count limit for this queue after account overrides and mediator defaults are applied; -1 = unlimited.\",\n \"minimum\": -1,\n \"type\": \"integer\"\n },\n \"oldestAgeSeconds\": {\n \"description\": \"Age of the oldest message in the queue, in seconds. Absent when the queue is empty or the mediator did not measure it.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"saturation\": {\n \"description\": \"count ÷ limit. Absent when the limit is unlimited. May exceed 1 when a limit was lowered below the current depth.\",\n \"minimum\": 0,\n \"type\": \"number\"\n }\n },\n \"required\": [\n \"count\",\n \"bytes\"\n ],\n \"title\": \"QueueDepth\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a messaging/stats/show request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/messaging/stats/show/0.1#response.\",\n \"properties\": {\n \"connections\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"websocketActive\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"websocketMax\": {\n \"description\": \"Configured ceiling; absent when unlimited.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"websocketActive\"\n ],\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"forwarding\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"circuitBreaker\": {\n \"description\": \"State of the store circuit breaker. `open` means the mediator is shedding store operations.\",\n \"enum\": [\n \"closed\",\n \"open\",\n \"halfOpen\"\n ],\n \"type\": \"string\"\n },\n \"queueLength\": {\n \"description\": \"Messages waiting to be forwarded to other mediators.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"queueLimit\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"queueLength\"\n ],\n \"type\": \"object\"\n },\n \"queues\": {\n \"additionalProperties\": false,\n \"description\": \"Aggregate of the mediator's most recent queue survey. Absent when no survey has completed.\",\n \"properties\": {\n \"accounts\": {\n \"description\": \"Accounts the survey covered.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"receive\": {\n \"$ref\": \"#/$defs/QueueDepth\",\n \"description\": \"Totals across every surveyed receive queue; `saturation` is the maximum of any single queue.\"\n },\n \"send\": {\n \"$ref\": \"#/$defs/QueueDepth\",\n \"description\": \"Totals across every surveyed send queue; `saturation` is the maximum of any single queue.\"\n },\n \"surveyedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"truncated\": {\n \"description\": \"The survey stopped before covering every account.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"surveyedAt\",\n \"accounts\"\n ],\n \"type\": \"object\"\n },\n \"startedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"totals\": {\n \"additionalProperties\": false,\n \"description\": \"Lifetime counters since the mediator's store was created. Monotonic; a client derives rates from successive readings.\",\n \"properties\": {\n \"deletedBytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"deletedCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"invitationsClaimed\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"invitationsCreated\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"receivedBytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"receivedCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sentBytes\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sentCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sessionsAuthenticated\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sessionsCreated\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"websocketClosed\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"websocketOpened\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"receivedCount\",\n \"receivedBytes\",\n \"sentCount\",\n \"sentBytes\",\n \"deletedCount\"\n ],\n \"type\": \"object\"\n },\n \"uptimeSeconds\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"version\": {\n \"description\": \"The mediator software's version string.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"version\",\n \"uptimeSeconds\",\n \"connections\",\n \"totals\",\n \"forwarding\"\n ],\n \"title\": \"Messaging — Show Mediator Statistics — response payload\",\n \"type\": \"object\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[];
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
#[test]
fn request_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:3b1f7c2e-6a4d-4b8e-9f10-2c5d7e8a9b01\",\n \"type\": \"https://trusttasks.org/spec/messaging/stats/show/0.1\",\n \"issuer\": \"did:web:admin.example\",\n \"recipient\": \"did:web:mediator.example\",\n \"issuedAt\": \"2026-09-21T10:00:00Z\",\n \"payload\": {},\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\": \"z4xQ...\"\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:3b1f7c2e-6a4d-4b8e-9f10-2c5d7e8a9b02\",\n \"type\": \"https://trusttasks.org/spec/messaging/stats/show/0.1#response\",\n \"threadId\": \"urn:uuid:3b1f7c2e-6a4d-4b8e-9f10-2c5d7e8a9b01\",\n \"issuer\": \"did:web:mediator.example\",\n \"recipient\": \"did:web:admin.example\",\n \"issuedAt\": \"2026-09-21T10:00:00Z\",\n \"payload\": {\n \"version\": \"0.21.0\",\n \"startedAt\": \"2026-09-19T08:12:40Z\",\n \"uptimeSeconds\": 179240,\n \"connections\": { \"websocketActive\": 412, \"websocketMax\": 10000 },\n \"totals\": {\n \"receivedCount\": 1843201,\n \"receivedBytes\": 2210937411,\n \"sentCount\": 1839977,\n \"sentBytes\": 2205114093,\n \"deletedCount\": 1838410,\n \"deletedBytes\": 2203001877,\n \"websocketOpened\": 22817,\n \"websocketClosed\": 22405,\n \"sessionsCreated\": 30112,\n \"sessionsAuthenticated\": 29870,\n \"invitationsCreated\": 214,\n \"invitationsClaimed\": 198\n },\n \"forwarding\": { \"queueLength\": 3, \"queueLimit\": 50000, \"circuitBreaker\": \"closed\" },\n \"queues\": {\n \"surveyedAt\": \"2026-09-21T09:59:12Z\",\n \"accounts\": 1288,\n \"truncated\": false,\n \"receive\": { \"count\": 1904, \"bytes\": 3912455, \"saturation\": 0.41 },\n \"send\": { \"count\": 2311, \"bytes\": 4402918, \"saturation\": 0.93 }\n }\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");
}
}