//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `persona/profile/usage`. Version: `1.0`.
#[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())
})
}
}
/**
Where a pool face may be worn. `anywhere` is the default and what an absent member means. `only` names the contexts it may be worn in, and a maintainer MUST refuse to wear it in any other (persona/binding/set `outsideReach`).
A tagged object rather than a bare list of contexts, deliberately: an empty list has been read as both 'unrestricted' and 'nowhere' in this family's neighbours, and a shape where the two cannot be confused is worth more than one where they must be remembered. So `only` requires at least one context, and 'nowhere' is not a reach — it is a retired face.
A context-local face has no reach: it lives in its context and is worn there by construction.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "FaceReach",
/// "description": "\nWhere a pool face may be worn. `anywhere` is the default and what an absent member means. `only` names the contexts it may be worn in, and a maintainer MUST refuse to wear it in any other (persona/binding/set `outsideReach`).\n\nA tagged object rather than a bare list of contexts, deliberately: an empty list has been read as both 'unrestricted' and 'nowhere' in this family's neighbours, and a shape where the two cannot be confused is worth more than one where they must be remembered. So `only` requires at least one context, and 'nowhere' is not a reach — it is a retired face.\n\nA context-local face has no reach: it lives in its context and is worn there by construction.",
/// "oneOf": [
/// {
/// "type": "object",
/// "required": [
/// "kind"
/// ],
/// "properties": {
/// "kind": {
/// "const": "anywhere"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "type": "object",
/// "required": [
/// "contextIds",
/// "kind"
/// ],
/// "properties": {
/// "contextIds": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "minLength": 1
/// },
/// "maxItems": 256,
/// "minItems": 1,
/// "uniqueItems": true
/// },
/// "kind": {
/// "const": "only"
/// }
/// },
/// "additionalProperties": false
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "kind", content = "contextIds")]
#[non_exhaustive]
pub enum FaceReach {
#[serde(rename = "anywhere")]
Anywhere,
#[serde(rename = "only")]
Only(Vec<FaceReachContextIdsItem>),
}
impl ::std::convert::From<Vec<FaceReachContextIdsItem>> for FaceReach {
fn from(value: Vec<FaceReachContextIdsItem>) -> Self {
Self::Only(value)
}
}
///`FaceReachContextIdsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct FaceReachContextIdsItem(::std::string::String);
impl ::std::ops::Deref for FaceReachContextIdsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<FaceReachContextIdsItem> for ::std::string::String {
fn from(value: FaceReachContextIdsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for FaceReachContextIdsItem {
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 FaceReachContextIdsItem {
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 FaceReachContextIdsItem {
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 FaceReachContextIdsItem {
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 FaceReachContextIdsItem {
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())
})
}
}
///Where one face is worn now: every context and persona wearing it. The answer a holder needs to audit a face's reach, and to see the contexts a face is part of before changing or retiring it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/persona/profile/usage/1.0",
/// "title": "Payload",
/// "description": "Where one face is worn now: every context and persona wearing it. The answer a holder needs to audit a face's reach, and to see the contexts a face is part of before changing or retiring it.",
/// "type": "object",
/// "required": [
/// "profileId"
/// ],
/// "properties": {
/// "contextId": {
/// "description": "The context of a context-local face. Omit for a pool face.",
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "profileId": {
/// "$ref": "#/definitions/Ulid"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The context of a context-local face. Omit for a pool face.
#[serde(
rename = "contextId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub context_id: ::std::option::Option<PayloadContextId>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(rename = "profileId")]
pub profile_id: Ulid,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The context of a context-local face. Omit for a pool face.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The context of a context-local face. Omit for a pool face.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadContextId(::std::string::String);
impl ::std::ops::Deref for PayloadContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadContextId> for ::std::string::String {
fn from(value: PayloadContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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())
})
}
}
///Success response to persona/profile/usage. Type https://trusttasks.org/spec/persona/profile/usage/1.0#response. An empty `usage` is a face worn nowhere — a normal state, not an error.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to persona/profile/usage. Type https://trusttasks.org/spec/persona/profile/usage/1.0#response. An empty `usage` is a face worn nowhere — a normal state, not an error.",
/// "type": "object",
/// "required": [
/// "profileId",
/// "usage"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "profileId": {
/// "$ref": "#/definitions/Ulid"
/// },
/// "reach": {
/// "description": "The face's reach, so the answer and the allow-list it is audited against arrive together. Absent for a context-local face.",
/// "$ref": "#/definitions/FaceReach"
/// },
/// "usage": {
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "boundAt",
/// "contextId",
/// "personaDid"
/// ],
/// "properties": {
/// "boundAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "contextId": {
/// "type": "string",
/// "minLength": 1
/// },
/// "personaDid": {
/// "type": "string",
/// "minLength": 1
/// },
/// "until": {
/// "description": "When wearing it here ends on its own. Absent when it lasts until changed.",
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 1024
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[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>,
#[serde(rename = "profileId")]
pub profile_id: Ulid,
///The face's reach, so the answer and the allow-list it is audited against arrive together. Absent for a context-local face.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub reach: ::std::option::Option<FaceReach>,
pub usage: ::std::vec::Vec<ResponseUsageItem>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseUsageItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "boundAt",
/// "contextId",
/// "personaDid"
/// ],
/// "properties": {
/// "boundAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "contextId": {
/// "type": "string",
/// "minLength": 1
/// },
/// "personaDid": {
/// "type": "string",
/// "minLength": 1
/// },
/// "until": {
/// "description": "When wearing it here ends on its own. Absent when it lasts until changed.",
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseUsageItem {
#[serde(rename = "boundAt")]
pub bound_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(rename = "contextId")]
pub context_id: ResponseUsageItemContextId,
#[serde(rename = "personaDid")]
pub persona_did: ResponseUsageItemPersonaDid,
///When wearing it here ends on its own. Absent when it lasts until changed.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub until: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
}
impl ResponseUsageItem {
pub fn builder() -> builder::ResponseUsageItem {
Default::default()
}
}
///`ResponseUsageItemContextId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseUsageItemContextId(::std::string::String);
impl ::std::ops::Deref for ResponseUsageItemContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseUsageItemContextId> for ::std::string::String {
fn from(value: ResponseUsageItemContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseUsageItemContextId {
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 ResponseUsageItemContextId {
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 ResponseUsageItemContextId {
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 ResponseUsageItemContextId {
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 ResponseUsageItemContextId {
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())
})
}
}
///`ResponseUsageItemPersonaDid`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseUsageItemPersonaDid(::std::string::String);
impl ::std::ops::Deref for ResponseUsageItemPersonaDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseUsageItemPersonaDid> for ::std::string::String {
fn from(value: ResponseUsageItemPersonaDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseUsageItemPersonaDid {
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 ResponseUsageItemPersonaDid {
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 ResponseUsageItemPersonaDid {
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 ResponseUsageItemPersonaDid {
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 ResponseUsageItemPersonaDid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ulid",
/// "description": "A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.",
/// "type": "string",
/// "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Ulid(::std::string::String);
impl ::std::ops::Deref for Ulid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Ulid> for ::std::string::String {
fn from(value: Ulid) -> Self {
value.0
}
}
impl ::std::str::FromStr for Ulid {
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("^[0-9A-HJKMNP-TV-Z]{26}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[0-9A-HJKMNP-TV-Z]{26}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Ulid {
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 Ulid {
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 Ulid {
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 Ulid {
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 {
context_id: ::std::result::Result<
::std::option::Option<super::PayloadContextId>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
profile_id: ::std::result::Result<super::Ulid, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
context_id: Ok(Default::default()),
ext: Ok(Default::default()),
profile_id: Err("no value supplied for profile_id".to_string()),
}
}
}
impl Payload {
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadContextId>>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {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 profile_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ulid>,
T::Error: ::std::fmt::Display,
{
self.profile_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for profile_id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
context_id: value.context_id?,
ext: value.ext?,
profile_id: value.profile_id?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
context_id: Ok(value.context_id),
ext: Ok(value.ext),
profile_id: Ok(value.profile_id),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
profile_id: ::std::result::Result<super::Ulid, ::std::string::String>,
reach:
::std::result::Result<::std::option::Option<super::FaceReach>, ::std::string::String>,
usage:
::std::result::Result<::std::vec::Vec<super::ResponseUsageItem>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
profile_id: Err("no value supplied for profile_id".to_string()),
reach: Ok(Default::default()),
usage: Err("no value supplied for usage".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 profile_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ulid>,
T::Error: ::std::fmt::Display,
{
self.profile_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for profile_id: {e}"));
self
}
pub fn reach<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::FaceReach>>,
T::Error: ::std::fmt::Display,
{
self.reach = value
.try_into()
.map_err(|e| format!("error converting supplied value for reach: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseUsageItem>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {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?,
profile_id: value.profile_id?,
reach: value.reach?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
profile_id: Ok(value.profile_id),
reach: Ok(value.reach),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseUsageItem {
bound_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
context_id: ::std::result::Result<super::ResponseUsageItemContextId, ::std::string::String>,
persona_did:
::std::result::Result<super::ResponseUsageItemPersonaDid, ::std::string::String>,
until: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
}
impl ::std::default::Default for ResponseUsageItem {
fn default() -> Self {
Self {
bound_at: Err("no value supplied for bound_at".to_string()),
context_id: Err("no value supplied for context_id".to_string()),
persona_did: Err("no value supplied for persona_did".to_string()),
until: Ok(Default::default()),
}
}
}
impl ResponseUsageItem {
pub fn bound_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.bound_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for bound_at: {e}"));
self
}
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseUsageItemContextId>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {e}"));
self
}
pub fn persona_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseUsageItemPersonaDid>,
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 until<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.until = value
.try_into()
.map_err(|e| format!("error converting supplied value for until: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseUsageItem> for super::ResponseUsageItem {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseUsageItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bound_at: value.bound_at?,
context_id: value.context_id?,
persona_did: value.persona_did?,
until: value.until?,
})
}
}
impl ::std::convert::From<super::ResponseUsageItem> for ResponseUsageItem {
fn from(value: super::ResponseUsageItem) -> Self {
Self {
bound_at: Ok(value.bound_at),
context_id: Ok(value.context_id),
persona_did: Ok(value.persona_did),
until: Ok(value.until),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/profile/usage/1.0";
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 \"FaceReach\": {\n \"description\": \"Where a pool face may be worn. `anywhere` is the default and what an absent member means. `only` names the contexts it may be worn in, and a maintainer MUST refuse to wear it in any other (persona/binding/set `outsideReach`).\\n\\nA tagged object rather than a bare list of contexts, deliberately: an empty list has been read as both 'unrestricted' and 'nowhere' in this family's neighbours, and a shape where the two cannot be confused is worth more than one where they must be remembered. So `only` requires at least one context, and 'nowhere' is not a reach — it is a retired face.\\n\\nA context-local face has no reach: it lives in its context and is worn there by construction.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"anywhere\"\n }\n },\n \"required\": [\n \"kind\"\n ],\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"contextIds\": {\n \"items\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 256,\n \"minItems\": 1,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"kind\": {\n \"const\": \"only\"\n }\n },\n \"required\": [\n \"kind\",\n \"contextIds\"\n ],\n \"type\": \"object\"\n }\n ],\n \"title\": \"FaceReach\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to persona/profile/usage. Type https://trusttasks.org/spec/persona/profile/usage/1.0#response. An empty `usage` is a face worn nowhere — a normal state, not an error.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\"\n },\n \"reach\": {\n \"$ref\": \"#/$defs/FaceReach\",\n \"description\": \"The face's reach, so the answer and the allow-list it is audited against arrive together. Absent for a context-local face.\"\n },\n \"usage\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"boundAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"contextId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"personaDid\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"until\": {\n \"description\": \"When wearing it here ends on its own. Absent when it lasts until changed.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"contextId\",\n \"personaDid\",\n \"boundAt\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 1024,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"profileId\",\n \"usage\"\n ],\n \"title\": \"Persona Profile Usage — response payload\",\n \"type\": \"object\"\n },\n \"Ulid\": {\n \"description\": \"A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.\",\n \"pattern\": \"^[0-9A-HJKMNP-TV-Z]{26}$\",\n \"title\": \"Ulid\",\n \"type\": \"string\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/persona/profile/usage/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Where one face is worn now: every context and persona wearing it. The answer a holder needs to audit a face's reach, and to see the contexts a face is part of before changing or retiring it.\",\n \"properties\": {\n \"contextId\": {\n \"description\": \"The context of a context-local face. Omit for a pool face.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\"\n }\n },\n \"required\": [\n \"profileId\"\n ],\n \"title\": \"Persona Profile Usage — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/profile/usage/1.0#response";
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 \"FaceReach\": {\n \"description\": \"Where a pool face may be worn. `anywhere` is the default and what an absent member means. `only` names the contexts it may be worn in, and a maintainer MUST refuse to wear it in any other (persona/binding/set `outsideReach`).\\n\\nA tagged object rather than a bare list of contexts, deliberately: an empty list has been read as both 'unrestricted' and 'nowhere' in this family's neighbours, and a shape where the two cannot be confused is worth more than one where they must be remembered. So `only` requires at least one context, and 'nowhere' is not a reach — it is a retired face.\\n\\nA context-local face has no reach: it lives in its context and is worn there by construction.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"anywhere\"\n }\n },\n \"required\": [\n \"kind\"\n ],\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"contextIds\": {\n \"items\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 256,\n \"minItems\": 1,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"kind\": {\n \"const\": \"only\"\n }\n },\n \"required\": [\n \"kind\",\n \"contextIds\"\n ],\n \"type\": \"object\"\n }\n ],\n \"title\": \"FaceReach\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to persona/profile/usage. Type https://trusttasks.org/spec/persona/profile/usage/1.0#response. An empty `usage` is a face worn nowhere — a normal state, not an error.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\"\n },\n \"reach\": {\n \"$ref\": \"#/$defs/FaceReach\",\n \"description\": \"The face's reach, so the answer and the allow-list it is audited against arrive together. Absent for a context-local face.\"\n },\n \"usage\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"boundAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"contextId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"personaDid\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"until\": {\n \"description\": \"When wearing it here ends on its own. Absent when it lasts until changed.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"contextId\",\n \"personaDid\",\n \"boundAt\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 1024,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"profileId\",\n \"usage\"\n ],\n \"title\": \"Persona Profile Usage — response payload\",\n \"type\": \"object\"\n },\n \"Ulid\": {\n \"description\": \"A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.\",\n \"pattern\": \"^[0-9A-HJKMNP-TV-Z]{26}$\",\n \"title\": \"Ulid\",\n \"type\": \"string\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[];