//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `did-management/server/metrics`. Version: `0.1`.
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = None;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One histogram's distribution, in the Prometheus cumulative-bucket convention: each bucket's `count` includes every observation at or below its `le`.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Histogram {
///Cumulative buckets, ordered by ascending `le`. Empty when the service exposes no bucket breakdown for this histogram — count and sum still apply. Always present, for the same reason as the snapshot's own arrays.
pub buckets: ::std::vec::Vec<HistogramBucket>,
///Total number of observations.
pub count: u64,
///Dimensions the distribution is broken down by. Absent or empty when the histogram carries none.
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub labels: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
///The histogram's stable name (e.g. `did_hosting_resolve_seconds`).
pub name: HistogramName,
///Sum of all observed values.
pub sum: f64,
}
impl Histogram {
pub fn builder() -> builder::Histogram {
Default::default()
}
}
///`HistogramBucket`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct HistogramBucket {
///Number of observations at or below `le`.
pub count: u64,
///Upper bound of this bucket, inclusive. The final bucket conventionally reports the same value as the histogram's own `count` at whatever `le` the service treats as its ceiling.
pub le: f64,
}
impl HistogramBucket {
pub fn builder() -> builder::HistogramBucket {
Default::default()
}
}
///The histogram's stable name (e.g. `did_hosting_resolve_seconds`).
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct HistogramName(::std::string::String);
impl ::std::ops::Deref for HistogramName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<HistogramName> for ::std::string::String {
fn from(value: HistogramName) -> Self {
value.0
}
}
impl ::std::str::FromStr for HistogramName {
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 HistogramName {
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 HistogramName {
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 HistogramName {
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 HistogramName {
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())
})
}
}
///One counter or gauge reading.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Metric {
///Dimensions the value is broken down by (e.g. `{"method": "resolve"}`). Absent or empty when the metric carries none.
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub labels: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
///The metric's stable name (e.g. `did_hosting_requests_total`). Implementation-defined; the framework imposes no vocabulary.
pub name: MetricName,
///The current reading.
pub value: f64,
}
impl Metric {
pub fn builder() -> builder::Metric {
Default::default()
}
}
///The metric's stable name (e.g. `did_hosting_requests_total`). Implementation-defined; the framework imposes no vocabulary.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct MetricName(::std::string::String);
impl ::std::ops::Deref for MetricName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<MetricName> for ::std::string::String {
fn from(value: MetricName) -> Self {
value.0
}
}
impl ::std::str::FromStr for MetricName {
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 MetricName {
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 MetricName {
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 MetricName {
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 MetricName {
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())
})
}
}
///`MetricsSnapshot`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct MetricsSnapshot {
///Monotonically increasing totals (e.g. requests served, errors raised). Empty when the service exposes none. Always present, so a collector can tell "no counters" from "the field was dropped".
pub counters: ::std::vec::Vec<Metric>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Point-in-time values that can rise or fall (e.g. open connections, queue depth). Empty when the service exposes none. Always present, for the same reason as counters.
pub gauges: ::std::vec::Vec<Metric>,
///Distributions of observed values (e.g. request latency). Empty when the service exposes none. Always present, for the same reason as counters.
pub histograms: ::std::vec::Vec<Histogram>,
///When the service read these values from its own instrumentation. Not the same as the envelope's issuedAt when a snapshot is cached briefly before answering.
#[serde(rename = "takenAt")]
pub taken_at: ::chrono::DateTime<::chrono::offset::Utc>,
}
impl MetricsSnapshot {
pub fn builder() -> builder::MetricsSnapshot {
Default::default()
}
}
///The read takes no selector — the whole snapshot is returned. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
#[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 service's current metrics snapshot. Carried in a Trust Task document whose type is https://trusttasks.org/spec/did-management/server/metrics/0.1#response.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub snapshot: MetricsSnapshot,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Histogram {
buckets:
::std::result::Result<::std::vec::Vec<super::HistogramBucket>, ::std::string::String>,
count: ::std::result::Result<u64, ::std::string::String>,
labels: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<super::HistogramName, ::std::string::String>,
sum: ::std::result::Result<f64, ::std::string::String>,
}
impl ::std::default::Default for Histogram {
fn default() -> Self {
Self {
buckets: Err("no value supplied for buckets".to_string()),
count: Err("no value supplied for count".to_string()),
labels: Ok(Default::default()),
name: Err("no value supplied for name".to_string()),
sum: Err("no value supplied for sum".to_string()),
}
}
}
impl Histogram {
pub fn buckets<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::HistogramBucket>>,
T::Error: ::std::fmt::Display,
{
self.buckets = value
.try_into()
.map_err(|e| format!("error converting supplied value for buckets: {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 labels<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.labels = value
.try_into()
.map_err(|e| format!("error converting supplied value for labels: {e}"));
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::HistogramName>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn sum<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<f64>,
T::Error: ::std::fmt::Display,
{
self.sum = value
.try_into()
.map_err(|e| format!("error converting supplied value for sum: {e}"));
self
}
}
impl ::std::convert::TryFrom<Histogram> for super::Histogram {
type Error = super::error::ConversionError;
fn try_from(
value: Histogram,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
buckets: value.buckets?,
count: value.count?,
labels: value.labels?,
name: value.name?,
sum: value.sum?,
})
}
}
impl ::std::convert::From<super::Histogram> for Histogram {
fn from(value: super::Histogram) -> Self {
Self {
buckets: Ok(value.buckets),
count: Ok(value.count),
labels: Ok(value.labels),
name: Ok(value.name),
sum: Ok(value.sum),
}
}
}
#[derive(Clone, Debug)]
pub struct HistogramBucket {
count: ::std::result::Result<u64, ::std::string::String>,
le: ::std::result::Result<f64, ::std::string::String>,
}
impl ::std::default::Default for HistogramBucket {
fn default() -> Self {
Self {
count: Err("no value supplied for count".to_string()),
le: Err("no value supplied for le".to_string()),
}
}
}
impl HistogramBucket {
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 le<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<f64>,
T::Error: ::std::fmt::Display,
{
self.le = value
.try_into()
.map_err(|e| format!("error converting supplied value for le: {e}"));
self
}
}
impl ::std::convert::TryFrom<HistogramBucket> for super::HistogramBucket {
type Error = super::error::ConversionError;
fn try_from(
value: HistogramBucket,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
count: value.count?,
le: value.le?,
})
}
}
impl ::std::convert::From<super::HistogramBucket> for HistogramBucket {
fn from(value: super::HistogramBucket) -> Self {
Self {
count: Ok(value.count),
le: Ok(value.le),
}
}
}
#[derive(Clone, Debug)]
pub struct Metric {
labels: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<super::MetricName, ::std::string::String>,
value: ::std::result::Result<f64, ::std::string::String>,
}
impl ::std::default::Default for Metric {
fn default() -> Self {
Self {
labels: Ok(Default::default()),
name: Err("no value supplied for name".to_string()),
value: Err("no value supplied for value".to_string()),
}
}
}
impl Metric {
pub fn labels<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.labels = value
.try_into()
.map_err(|e| format!("error converting supplied value for labels: {e}"));
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MetricName>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn value<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<f64>,
T::Error: ::std::fmt::Display,
{
self.value = value
.try_into()
.map_err(|e| format!("error converting supplied value for value: {e}"));
self
}
}
impl ::std::convert::TryFrom<Metric> for super::Metric {
type Error = super::error::ConversionError;
fn try_from(value: Metric) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
labels: value.labels?,
name: value.name?,
value: value.value?,
})
}
}
impl ::std::convert::From<super::Metric> for Metric {
fn from(value: super::Metric) -> Self {
Self {
labels: Ok(value.labels),
name: Ok(value.name),
value: Ok(value.value),
}
}
}
#[derive(Clone, Debug)]
pub struct MetricsSnapshot {
counters: ::std::result::Result<::std::vec::Vec<super::Metric>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
gauges: ::std::result::Result<::std::vec::Vec<super::Metric>, ::std::string::String>,
histograms: ::std::result::Result<::std::vec::Vec<super::Histogram>, ::std::string::String>,
taken_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
}
impl ::std::default::Default for MetricsSnapshot {
fn default() -> Self {
Self {
counters: Err("no value supplied for counters".to_string()),
ext: Ok(Default::default()),
gauges: Err("no value supplied for gauges".to_string()),
histograms: Err("no value supplied for histograms".to_string()),
taken_at: Err("no value supplied for taken_at".to_string()),
}
}
}
impl MetricsSnapshot {
pub fn counters<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Metric>>,
T::Error: ::std::fmt::Display,
{
self.counters = value
.try_into()
.map_err(|e| format!("error converting supplied value for counters: {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 gauges<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Metric>>,
T::Error: ::std::fmt::Display,
{
self.gauges = value
.try_into()
.map_err(|e| format!("error converting supplied value for gauges: {e}"));
self
}
pub fn histograms<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Histogram>>,
T::Error: ::std::fmt::Display,
{
self.histograms = value
.try_into()
.map_err(|e| format!("error converting supplied value for histograms: {e}"));
self
}
pub fn taken_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.taken_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for taken_at: {e}"));
self
}
}
impl ::std::convert::TryFrom<MetricsSnapshot> for super::MetricsSnapshot {
type Error = super::error::ConversionError;
fn try_from(
value: MetricsSnapshot,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
counters: value.counters?,
ext: value.ext?,
gauges: value.gauges?,
histograms: value.histograms?,
taken_at: value.taken_at?,
})
}
}
impl ::std::convert::From<super::MetricsSnapshot> for MetricsSnapshot {
fn from(value: super::MetricsSnapshot) -> Self {
Self {
counters: Ok(value.counters),
ext: Ok(value.ext),
gauges: Ok(value.gauges),
histograms: Ok(value.histograms),
taken_at: Ok(value.taken_at),
}
}
}
#[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 Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
snapshot: ::std::result::Result<super::MetricsSnapshot, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
snapshot: Err("no value supplied for snapshot".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 snapshot<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MetricsSnapshot>,
T::Error: ::std::fmt::Display,
{
self.snapshot = value
.try_into()
.map_err(|e| format!("error converting supplied value for snapshot: {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?,
snapshot: value.snapshot?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
snapshot: Ok(value.snapshot),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/did-management/server/metrics/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Histogram\":{\"additionalProperties\":false,\"description\":\"One histogram's distribution, in the Prometheus cumulative-bucket convention: each bucket's `count` includes every observation at or below its `le`.\",\"properties\":{\"buckets\":{\"description\":\"Cumulative buckets, ordered by ascending `le`. Empty when the service exposes no bucket breakdown for this histogram — count and sum still apply. Always present, for the same reason as the snapshot's own arrays.\",\"items\":{\"$ref\":\"#/$defs/HistogramBucket\"},\"type\":\"array\"},\"count\":{\"description\":\"Total number of observations.\",\"minimum\":0,\"type\":\"integer\"},\"labels\":{\"additionalProperties\":{\"type\":\"string\"},\"description\":\"Dimensions the distribution is broken down by. Absent or empty when the histogram carries none.\",\"type\":\"object\"},\"name\":{\"description\":\"The histogram's stable name (e.g. `did_hosting_resolve_seconds`).\",\"minLength\":1,\"type\":\"string\"},\"sum\":{\"description\":\"Sum of all observed values.\",\"type\":\"number\"}},\"required\":[\"name\",\"count\",\"sum\",\"buckets\"],\"title\":\"Histogram\",\"type\":\"object\"},\"HistogramBucket\":{\"additionalProperties\":false,\"properties\":{\"count\":{\"description\":\"Number of observations at or below `le`.\",\"minimum\":0,\"type\":\"integer\"},\"le\":{\"description\":\"Upper bound of this bucket, inclusive. The final bucket conventionally reports the same value as the histogram's own `count` at whatever `le` the service treats as its ceiling.\",\"type\":\"number\"}},\"required\":[\"le\",\"count\"],\"title\":\"HistogramBucket\",\"type\":\"object\"},\"Metric\":{\"additionalProperties\":false,\"description\":\"One counter or gauge reading.\",\"properties\":{\"labels\":{\"additionalProperties\":{\"type\":\"string\"},\"description\":\"Dimensions the value is broken down by (e.g. `{\\\"method\\\": \\\"resolve\\\"}`). Absent or empty when the metric carries none.\",\"type\":\"object\"},\"name\":{\"description\":\"The metric's stable name (e.g. `did_hosting_requests_total`). Implementation-defined; the framework imposes no vocabulary.\",\"minLength\":1,\"type\":\"string\"},\"value\":{\"description\":\"The current reading.\",\"type\":\"number\"}},\"required\":[\"name\",\"value\"],\"title\":\"Metric\",\"type\":\"object\"},\"MetricsSnapshot\":{\"additionalProperties\":false,\"properties\":{\"counters\":{\"description\":\"Monotonically increasing totals (e.g. requests served, errors raised). Empty when the service exposes none. Always present, so a collector can tell \\\"no counters\\\" from \\\"the field was dropped\\\".\",\"items\":{\"$ref\":\"#/$defs/Metric\"},\"type\":\"array\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"gauges\":{\"description\":\"Point-in-time values that can rise or fall (e.g. open connections, queue depth). Empty when the service exposes none. Always present, for the same reason as counters.\",\"items\":{\"$ref\":\"#/$defs/Metric\"},\"type\":\"array\"},\"histograms\":{\"description\":\"Distributions of observed values (e.g. request latency). Empty when the service exposes none. Always present, for the same reason as counters.\",\"items\":{\"$ref\":\"#/$defs/Histogram\"},\"type\":\"array\"},\"takenAt\":{\"description\":\"When the service read these values from its own instrumentation. Not the same as the envelope's issuedAt when a snapshot is cached briefly before answering.\",\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"takenAt\",\"counters\",\"gauges\",\"histograms\"],\"title\":\"MetricsSnapshot\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"The service's current metrics snapshot. Carried in a Trust Task document whose type is https://trusttasks.org/spec/did-management/server/metrics/0.1#response.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"snapshot\":{\"$ref\":\"#/$defs/MetricsSnapshot\"}},\"required\":[\"snapshot\"],\"title\":\"DID Management — Server Metrics — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/did-management/server/metrics/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"The read takes no selector — the whole snapshot is returned. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\"}},\"title\":\"DID Management — Server Metrics — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/did-management/server/metrics/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Histogram\":{\"additionalProperties\":false,\"description\":\"One histogram's distribution, in the Prometheus cumulative-bucket convention: each bucket's `count` includes every observation at or below its `le`.\",\"properties\":{\"buckets\":{\"description\":\"Cumulative buckets, ordered by ascending `le`. Empty when the service exposes no bucket breakdown for this histogram — count and sum still apply. Always present, for the same reason as the snapshot's own arrays.\",\"items\":{\"$ref\":\"#/$defs/HistogramBucket\"},\"type\":\"array\"},\"count\":{\"description\":\"Total number of observations.\",\"minimum\":0,\"type\":\"integer\"},\"labels\":{\"additionalProperties\":{\"type\":\"string\"},\"description\":\"Dimensions the distribution is broken down by. Absent or empty when the histogram carries none.\",\"type\":\"object\"},\"name\":{\"description\":\"The histogram's stable name (e.g. `did_hosting_resolve_seconds`).\",\"minLength\":1,\"type\":\"string\"},\"sum\":{\"description\":\"Sum of all observed values.\",\"type\":\"number\"}},\"required\":[\"name\",\"count\",\"sum\",\"buckets\"],\"title\":\"Histogram\",\"type\":\"object\"},\"HistogramBucket\":{\"additionalProperties\":false,\"properties\":{\"count\":{\"description\":\"Number of observations at or below `le`.\",\"minimum\":0,\"type\":\"integer\"},\"le\":{\"description\":\"Upper bound of this bucket, inclusive. The final bucket conventionally reports the same value as the histogram's own `count` at whatever `le` the service treats as its ceiling.\",\"type\":\"number\"}},\"required\":[\"le\",\"count\"],\"title\":\"HistogramBucket\",\"type\":\"object\"},\"Metric\":{\"additionalProperties\":false,\"description\":\"One counter or gauge reading.\",\"properties\":{\"labels\":{\"additionalProperties\":{\"type\":\"string\"},\"description\":\"Dimensions the value is broken down by (e.g. `{\\\"method\\\": \\\"resolve\\\"}`). Absent or empty when the metric carries none.\",\"type\":\"object\"},\"name\":{\"description\":\"The metric's stable name (e.g. `did_hosting_requests_total`). Implementation-defined; the framework imposes no vocabulary.\",\"minLength\":1,\"type\":\"string\"},\"value\":{\"description\":\"The current reading.\",\"type\":\"number\"}},\"required\":[\"name\",\"value\"],\"title\":\"Metric\",\"type\":\"object\"},\"MetricsSnapshot\":{\"additionalProperties\":false,\"properties\":{\"counters\":{\"description\":\"Monotonically increasing totals (e.g. requests served, errors raised). Empty when the service exposes none. Always present, so a collector can tell \\\"no counters\\\" from \\\"the field was dropped\\\".\",\"items\":{\"$ref\":\"#/$defs/Metric\"},\"type\":\"array\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"gauges\":{\"description\":\"Point-in-time values that can rise or fall (e.g. open connections, queue depth). Empty when the service exposes none. Always present, for the same reason as counters.\",\"items\":{\"$ref\":\"#/$defs/Metric\"},\"type\":\"array\"},\"histograms\":{\"description\":\"Distributions of observed values (e.g. request latency). Empty when the service exposes none. Always present, for the same reason as counters.\",\"items\":{\"$ref\":\"#/$defs/Histogram\"},\"type\":\"array\"},\"takenAt\":{\"description\":\"When the service read these values from its own instrumentation. Not the same as the envelope's issuedAt when a snapshot is cached briefly before answering.\",\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"takenAt\",\"counters\",\"gauges\",\"histograms\"],\"title\":\"MetricsSnapshot\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"The service's current metrics snapshot. Carried in a Trust Task document whose type is https://trusttasks.org/spec/did-management/server/metrics/0.1#response.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"snapshot\":{\"$ref\":\"#/$defs/MetricsSnapshot\"}},\"required\":[\"snapshot\"],\"title\":\"DID Management — Server Metrics — response payload\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[];