//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vtc/relationships/graph`. Version: `0.2`.
/// 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 edge between a **pair** of identifiers, carrying every half published between them.
`0.1` called each credential an edge, which made a DTG edge inexpressible: the two directed halves between the same pair are one relationship, and a consumer given a flat list had to re-derive that pairing — sorting DIDs, grouping, and deciding for itself what `complete` means. Two implementations doing that independently will disagree at the margins, which is exactly the reasoning a schema exists to settle once.*/
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct GraphEdge {
///True when both endpoints have asserted about each other. The distinction a flat list cannot make: an edge asserted by one party is a claim, and an edge asserted by both is a relationship.
pub complete: bool,
///The two endpoints, DID-sorted. Sorting gives the pair one identity whichever half was published first. Both entries are equal only for a self-issued credential.
pub endpoints: [GraphEdgeEndpointsItem; 2usize],
///Every credential published between the endpoints, oldest first. One for a half-edge, two for the ordinary reciprocated edge, more where a party has re-issued.
pub halves: ::std::vec::Vec<GraphHalf>,
}
impl GraphEdge {
pub fn builder() -> builder::GraphEdge {
Default::default()
}
}
///`GraphEdgeEndpointsItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GraphEdgeEndpointsItem(::std::string::String);
impl ::std::ops::Deref for GraphEdgeEndpointsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GraphEdgeEndpointsItem> for ::std::string::String {
fn from(value: GraphEdgeEndpointsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for GraphEdgeEndpointsItem {
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("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GraphEdgeEndpointsItem {
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 GraphEdgeEndpointsItem {
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 GraphEdgeEndpointsItem {
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 GraphEdgeEndpointsItem {
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 published relationship credential: a **directed half** of an edge, asserted by `issuerDid` about `subjectDid`.
Body-free on purpose — the graph shows the shape of the trust network, not credential contents. `id` is the row identifier a revoke takes.*/
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct GraphHalf {
#[serde(rename = "createdAt")]
pub created_at: ::chrono::DateTime<::chrono::offset::Utc>,
pub id: GraphHalfId,
///The asserting party.
#[serde(rename = "issuerDid")]
pub issuer_did: GraphHalfIssuerDid,
/**
The persona this issuer has asserted on this half, when they have.
The one place deliberate correlation becomes visible: two pairwise halves carrying the same `personaDid` are the same party, said so by that party. A consumer that cannot read it cannot honour a correlation its subject chose to publish.*/
#[serde(
rename = "personaDid",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub persona_did: ::std::option::Option<GraphHalfPersonaDid>,
///The party asserted about.
#[serde(rename = "subjectDid")]
pub subject_did: GraphHalfSubjectDid,
}
impl GraphHalf {
pub fn builder() -> builder::GraphHalf {
Default::default()
}
}
///`GraphHalfId`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GraphHalfId(::std::string::String);
impl ::std::ops::Deref for GraphHalfId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GraphHalfId> for ::std::string::String {
fn from(value: GraphHalfId) -> Self {
value.0
}
}
impl ::std::str::FromStr for GraphHalfId {
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 GraphHalfId {
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 GraphHalfId {
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 GraphHalfId {
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 GraphHalfId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The asserting party.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GraphHalfIssuerDid(::std::string::String);
impl ::std::ops::Deref for GraphHalfIssuerDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GraphHalfIssuerDid> for ::std::string::String {
fn from(value: GraphHalfIssuerDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for GraphHalfIssuerDid {
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("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GraphHalfIssuerDid {
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 GraphHalfIssuerDid {
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 GraphHalfIssuerDid {
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 GraphHalfIssuerDid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/**
The persona this issuer has asserted on this half, when they have.
The one place deliberate correlation becomes visible: two pairwise halves carrying the same `personaDid` are the same party, said so by that party. A consumer that cannot read it cannot honour a correlation its subject chose to publish.*/
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GraphHalfPersonaDid(::std::string::String);
impl ::std::ops::Deref for GraphHalfPersonaDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GraphHalfPersonaDid> for ::std::string::String {
fn from(value: GraphHalfPersonaDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for GraphHalfPersonaDid {
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("^did:|^$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:|^$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GraphHalfPersonaDid {
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 GraphHalfPersonaDid {
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 GraphHalfPersonaDid {
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 GraphHalfPersonaDid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The party asserted about.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GraphHalfSubjectDid(::std::string::String);
impl ::std::ops::Deref for GraphHalfSubjectDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GraphHalfSubjectDid> for ::std::string::String {
fn from(value: GraphHalfSubjectDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for GraphHalfSubjectDid {
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("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GraphHalfSubjectDid {
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 GraphHalfSubjectDid {
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 GraphHalfSubjectDid {
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 GraphHalfSubjectDid {
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())
})
}
}
///`GraphNode`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct GraphNode {
///A DID participating in at least one live relationship.
pub did: GraphNodeDid,
}
impl GraphNode {
pub fn builder() -> builder::GraphNode {
Default::default()
}
}
///A DID participating in at least one live relationship.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GraphNodeDid(::std::string::String);
impl ::std::ops::Deref for GraphNodeDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GraphNodeDid> for ::std::string::String {
fn from(value: GraphNodeDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for GraphNodeDid {
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 GraphNodeDid {
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 GraphNodeDid {
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 GraphNodeDid {
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 GraphNodeDid {
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`
///
#[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()
}
}
///`Response`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///One per **pair** of identifiers with at least one live credential between them, not one per credential.
pub edges: ::std::vec::Vec<GraphEdge>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///One per distinct DID appearing in a live edge. No isolated nodes.
pub nodes: ::std::vec::Vec<GraphNode>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct GraphEdge {
complete: ::std::result::Result<bool, ::std::string::String>,
endpoints:
::std::result::Result<[super::GraphEdgeEndpointsItem; 2usize], ::std::string::String>,
halves: ::std::result::Result<::std::vec::Vec<super::GraphHalf>, ::std::string::String>,
}
impl ::std::default::Default for GraphEdge {
fn default() -> Self {
Self {
complete: Err("no value supplied for complete".to_string()),
endpoints: Err("no value supplied for endpoints".to_string()),
halves: Err("no value supplied for halves".to_string()),
}
}
}
impl GraphEdge {
pub fn complete<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.complete = value
.try_into()
.map_err(|e| format!("error converting supplied value for complete: {e}"));
self
}
pub fn endpoints<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<[super::GraphEdgeEndpointsItem; 2usize]>,
T::Error: ::std::fmt::Display,
{
self.endpoints = value
.try_into()
.map_err(|e| format!("error converting supplied value for endpoints: {e}"));
self
}
pub fn halves<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::GraphHalf>>,
T::Error: ::std::fmt::Display,
{
self.halves = value
.try_into()
.map_err(|e| format!("error converting supplied value for halves: {e}"));
self
}
}
impl ::std::convert::TryFrom<GraphEdge> for super::GraphEdge {
type Error = super::error::ConversionError;
fn try_from(
value: GraphEdge,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
complete: value.complete?,
endpoints: value.endpoints?,
halves: value.halves?,
})
}
}
impl ::std::convert::From<super::GraphEdge> for GraphEdge {
fn from(value: super::GraphEdge) -> Self {
Self {
complete: Ok(value.complete),
endpoints: Ok(value.endpoints),
halves: Ok(value.halves),
}
}
}
#[derive(Clone, Debug)]
pub struct GraphHalf {
created_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
id: ::std::result::Result<super::GraphHalfId, ::std::string::String>,
issuer_did: ::std::result::Result<super::GraphHalfIssuerDid, ::std::string::String>,
persona_did: ::std::result::Result<
::std::option::Option<super::GraphHalfPersonaDid>,
::std::string::String,
>,
subject_did: ::std::result::Result<super::GraphHalfSubjectDid, ::std::string::String>,
}
impl ::std::default::Default for GraphHalf {
fn default() -> Self {
Self {
created_at: Err("no value supplied for created_at".to_string()),
id: Err("no value supplied for id".to_string()),
issuer_did: Err("no value supplied for issuer_did".to_string()),
persona_did: Ok(Default::default()),
subject_did: Err("no value supplied for subject_did".to_string()),
}
}
}
impl GraphHalf {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for created_at: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GraphHalfId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn issuer_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GraphHalfIssuerDid>,
T::Error: ::std::fmt::Display,
{
self.issuer_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for issuer_did: {e}"));
self
}
pub fn persona_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::GraphHalfPersonaDid>>,
T::Error: ::std::fmt::Display,
{
self.persona_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for persona_did: {e}"));
self
}
pub fn subject_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GraphHalfSubjectDid>,
T::Error: ::std::fmt::Display,
{
self.subject_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for subject_did: {e}"));
self
}
}
impl ::std::convert::TryFrom<GraphHalf> for super::GraphHalf {
type Error = super::error::ConversionError;
fn try_from(
value: GraphHalf,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
id: value.id?,
issuer_did: value.issuer_did?,
persona_did: value.persona_did?,
subject_did: value.subject_did?,
})
}
}
impl ::std::convert::From<super::GraphHalf> for GraphHalf {
fn from(value: super::GraphHalf) -> Self {
Self {
created_at: Ok(value.created_at),
id: Ok(value.id),
issuer_did: Ok(value.issuer_did),
persona_did: Ok(value.persona_did),
subject_did: Ok(value.subject_did),
}
}
}
#[derive(Clone, Debug)]
pub struct GraphNode {
did: ::std::result::Result<super::GraphNodeDid, ::std::string::String>,
}
impl ::std::default::Default for GraphNode {
fn default() -> Self {
Self {
did: Err("no value supplied for did".to_string()),
}
}
}
impl GraphNode {
pub fn did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GraphNodeDid>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {e}"));
self
}
}
impl ::std::convert::TryFrom<GraphNode> for super::GraphNode {
type Error = super::error::ConversionError;
fn try_from(
value: GraphNode,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { did: value.did? })
}
}
impl ::std::convert::From<super::GraphNode> for GraphNode {
fn from(value: super::GraphNode) -> Self {
Self { did: Ok(value.did) }
}
}
#[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 {
edges: ::std::result::Result<::std::vec::Vec<super::GraphEdge>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
nodes: ::std::result::Result<::std::vec::Vec<super::GraphNode>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
edges: Err("no value supplied for edges".to_string()),
ext: Ok(Default::default()),
nodes: Err("no value supplied for nodes".to_string()),
}
}
}
impl Response {
pub fn edges<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::GraphEdge>>,
T::Error: ::std::fmt::Display,
{
self.edges = value
.try_into()
.map_err(|e| format!("error converting supplied value for edges: {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 nodes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::GraphNode>>,
T::Error: ::std::fmt::Display,
{
self.nodes = value
.try_into()
.map_err(|e| format!("error converting supplied value for nodes: {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 {
edges: value.edges?,
ext: value.ext?,
nodes: value.nodes?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
edges: Ok(value.edges),
ext: Ok(value.ext),
nodes: Ok(value.nodes),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vtc/relationships/graph/0.2";
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\"},\"GraphEdge\":{\"$anchor\":\"graphEdge\",\"additionalProperties\":false,\"description\":\"One edge between a **pair** of identifiers, carrying every half published between them.\\n\\n`0.1` called each credential an edge, which made a DTG edge inexpressible: the two directed halves between the same pair are one relationship, and a consumer given a flat list had to re-derive that pairing — sorting DIDs, grouping, and deciding for itself what `complete` means. Two implementations doing that independently will disagree at the margins, which is exactly the reasoning a schema exists to settle once.\",\"properties\":{\"complete\":{\"description\":\"True when both endpoints have asserted about each other. The distinction a flat list cannot make: an edge asserted by one party is a claim, and an edge asserted by both is a relationship.\",\"type\":\"boolean\"},\"endpoints\":{\"description\":\"The two endpoints, DID-sorted. Sorting gives the pair one identity whichever half was published first. Both entries are equal only for a self-issued credential.\",\"items\":{\"pattern\":\"^did:\",\"type\":\"string\"},\"maxItems\":2,\"minItems\":2,\"type\":\"array\"},\"halves\":{\"description\":\"Every credential published between the endpoints, oldest first. One for a half-edge, two for the ordinary reciprocated edge, more where a party has re-issued.\",\"items\":{\"$ref\":\"#/$defs/GraphHalf\"},\"minItems\":1,\"type\":\"array\"}},\"required\":[\"endpoints\",\"halves\",\"complete\"],\"title\":\"GraphEdge\",\"type\":\"object\"},\"GraphHalf\":{\"$anchor\":\"graphHalf\",\"additionalProperties\":false,\"description\":\"One published relationship credential: a **directed half** of an edge, asserted by `issuerDid` about `subjectDid`.\\n\\nBody-free on purpose — the graph shows the shape of the trust network, not credential contents. `id` is the row identifier a revoke takes.\",\"properties\":{\"createdAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"minLength\":1,\"type\":\"string\"},\"issuerDid\":{\"description\":\"The asserting party.\",\"pattern\":\"^did:\",\"type\":\"string\"},\"personaDid\":{\"description\":\"The persona this issuer has asserted on this half, when they have.\\n\\nThe one place deliberate correlation becomes visible: two pairwise halves carrying the same `personaDid` are the same party, said so by that party. A consumer that cannot read it cannot honour a correlation its subject chose to publish.\",\"pattern\":\"^did:|^$\",\"type\":[\"string\",\"null\"]},\"subjectDid\":{\"description\":\"The party asserted about.\",\"pattern\":\"^did:\",\"type\":\"string\"}},\"required\":[\"id\",\"issuerDid\",\"subjectDid\",\"createdAt\"],\"title\":\"GraphHalf\",\"type\":\"object\"},\"GraphNode\":{\"$anchor\":\"graphNode\",\"additionalProperties\":false,\"properties\":{\"did\":{\"description\":\"A DID participating in at least one live relationship.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"did\"],\"title\":\"GraphNode\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"edges\":{\"description\":\"One per **pair** of identifiers with at least one live credential between them, not one per credential.\",\"items\":{\"$ref\":\"#/$defs/GraphEdge\"},\"type\":\"array\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"nodes\":{\"description\":\"One per distinct DID appearing in a live edge. No isolated nodes.\",\"items\":{\"$ref\":\"#/$defs/GraphNode\"},\"type\":\"array\"}},\"required\":[\"nodes\",\"edges\"],\"title\":\"VTC Relationships Graph — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vtc/relationships/graph/0.2\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\"}},\"title\":\"VTC Relationships Graph — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vtc/relationships/graph/0.2#response";
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\"},\"GraphEdge\":{\"$anchor\":\"graphEdge\",\"additionalProperties\":false,\"description\":\"One edge between a **pair** of identifiers, carrying every half published between them.\\n\\n`0.1` called each credential an edge, which made a DTG edge inexpressible: the two directed halves between the same pair are one relationship, and a consumer given a flat list had to re-derive that pairing — sorting DIDs, grouping, and deciding for itself what `complete` means. Two implementations doing that independently will disagree at the margins, which is exactly the reasoning a schema exists to settle once.\",\"properties\":{\"complete\":{\"description\":\"True when both endpoints have asserted about each other. The distinction a flat list cannot make: an edge asserted by one party is a claim, and an edge asserted by both is a relationship.\",\"type\":\"boolean\"},\"endpoints\":{\"description\":\"The two endpoints, DID-sorted. Sorting gives the pair one identity whichever half was published first. Both entries are equal only for a self-issued credential.\",\"items\":{\"pattern\":\"^did:\",\"type\":\"string\"},\"maxItems\":2,\"minItems\":2,\"type\":\"array\"},\"halves\":{\"description\":\"Every credential published between the endpoints, oldest first. One for a half-edge, two for the ordinary reciprocated edge, more where a party has re-issued.\",\"items\":{\"$ref\":\"#/$defs/GraphHalf\"},\"minItems\":1,\"type\":\"array\"}},\"required\":[\"endpoints\",\"halves\",\"complete\"],\"title\":\"GraphEdge\",\"type\":\"object\"},\"GraphHalf\":{\"$anchor\":\"graphHalf\",\"additionalProperties\":false,\"description\":\"One published relationship credential: a **directed half** of an edge, asserted by `issuerDid` about `subjectDid`.\\n\\nBody-free on purpose — the graph shows the shape of the trust network, not credential contents. `id` is the row identifier a revoke takes.\",\"properties\":{\"createdAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"minLength\":1,\"type\":\"string\"},\"issuerDid\":{\"description\":\"The asserting party.\",\"pattern\":\"^did:\",\"type\":\"string\"},\"personaDid\":{\"description\":\"The persona this issuer has asserted on this half, when they have.\\n\\nThe one place deliberate correlation becomes visible: two pairwise halves carrying the same `personaDid` are the same party, said so by that party. A consumer that cannot read it cannot honour a correlation its subject chose to publish.\",\"pattern\":\"^did:|^$\",\"type\":[\"string\",\"null\"]},\"subjectDid\":{\"description\":\"The party asserted about.\",\"pattern\":\"^did:\",\"type\":\"string\"}},\"required\":[\"id\",\"issuerDid\",\"subjectDid\",\"createdAt\"],\"title\":\"GraphHalf\",\"type\":\"object\"},\"GraphNode\":{\"$anchor\":\"graphNode\",\"additionalProperties\":false,\"properties\":{\"did\":{\"description\":\"A DID participating in at least one live relationship.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"did\"],\"title\":\"GraphNode\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"edges\":{\"description\":\"One per **pair** of identifiers with at least one live credential between them, not one per credential.\",\"items\":{\"$ref\":\"#/$defs/GraphEdge\"},\"type\":\"array\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"nodes\":{\"description\":\"One per distinct DID appearing in a live edge. No isolated nodes.\",\"items\":{\"$ref\":\"#/$defs/GraphNode\"},\"type\":\"array\"}},\"required\":[\"nodes\",\"edges\"],\"title\":\"VTC Relationships Graph — 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] = &[];