//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `persona/local/profile/put`. 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())
}
}
}
/**
The vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.
The token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.
The `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ClaimType",
/// "description": "\nThe vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.\n\nThe token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.\n\nThe `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1,
/// "pattern": "^(x:)?[a-z][a-zA-Z0-9]*(\\.[a-z][a-zA-Z0-9]*)*$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ClaimType(::std::string::String);
impl ::std::ops::Deref for ClaimType {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ClaimType> for ::std::string::String {
fn from(value: ClaimType) -> Self {
value.0
}
}
impl ::std::str::FromStr for ClaimType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^(x:)?[a-z][a-zA-Z0-9]*(\\.[a-z][a-zA-Z0-9]*)*$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^(x:)?[a-z][a-zA-Z0-9]*(\\.[a-z][a-zA-Z0-9]*)*$\"".into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ClaimType {
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 ClaimType {
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 ClaimType {
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 ClaimType {
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())
})
}
}
///Optimistic-concurrency precondition. A positive value requires the record's current `version` to equal it exactly; zero means create-only and applies only when no live record exists at the address.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ExpectedVersion",
/// "description": "Optimistic-concurrency precondition. A positive value requires the record's current `version` to equal it exactly; zero means create-only and applies only when no live record exists at the address.",
/// "type": "integer",
/// "minimum": 0.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ExpectedVersion(pub u64);
impl ::std::ops::Deref for ExpectedVersion {
type Target = u64;
fn deref(&self) -> &u64 {
&self.0
}
}
impl ::std::convert::From<ExpectedVersion> for u64 {
fn from(value: ExpectedVersion) -> Self {
value.0
}
}
impl ::std::convert::From<u64> for ExpectedVersion {
fn from(value: u64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for ExpectedVersion {
type Err = <u64 as ::std::str::FromStr>::Err;
fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
Ok(Self(value.parse()?))
}
}
impl ::std::convert::TryFrom<&str> for ExpectedVersion {
type Error = <u64 as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for ExpectedVersion {
type Error = <u64 as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for ExpectedVersion {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
///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())
})
}
}
///Compose a throwaway profile inside a context, from values supplied here rather than drawn from the holder's pool. Inline entries only: a reference is refused, and that refusal is what keeps the local surface pool-free.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/persona/local/profile/put/1.0",
/// "title": "Payload",
/// "description": "Compose a throwaway profile inside a context, from values supplied here rather than drawn from the holder's pool. Inline entries only: a reference is refused, and that refusal is what keeps the local surface pool-free.",
/// "type": "object",
/// "required": [
/// "contextId",
/// "entries",
/// "name"
/// ],
/// "properties": {
/// "contextId": {
/// "type": "string",
/// "minLength": 1
/// },
/// "entries": {
/// "type": "array",
/// "items": {
/// "description": "Inline entries only. The `ref`, pinned and override forms of a pool profile are absent from this schema deliberately — a context-local profile that could reference the pool would be a context-authored object acquiring pool reach, which is exactly what the boundary exists to prevent.",
/// "type": "object",
/// "required": [
/// "inline"
/// ],
/// "properties": {
/// "inline": {
/// "description": "\nA value the holder keeps in this context and nowhere else.\n\nDeliberately NARROWER than a pool profile's inline entry, which also carries `provenance` and requires it. There is no `provenance` member here, and its absence is a rule rather than an omission: a `credentialBacked` provenance names a `credentialId` and a `claimPath`, and a value authored inside a context has nowhere to put either. So a context-local value is SELF-ASSERTED by construction, and a maintainer MUST present it as such.\n\nThat is the same boundary the missing `ref`, pinned and override forms enforce, one member along. Those stop a context-authored object acquiring pool REACH; this stops it acquiring an issuer's AUTHORITY — asserting that a value is attested when no credential was ever checked, over a value the issuer never saw. A holder who needs a context to present an attested claim binds a pool profile, which is holder-authorized, rather than authoring one here.\n\nAdding a `provenance` member to this object would therefore be a privilege escalation dressed as a convenience, not a gap to fill.",
/// "type": "object",
/// "required": [
/// "type",
/// "value",
/// "valueType"
/// ],
/// "properties": {
/// "label": {
/// "type": "string",
/// "maxLength": 128
/// },
/// "type": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "value": {},
/// "valueType": {
/// "$ref": "#/definitions/ValueType"
/// }
/// },
/// "additionalProperties": false
/// },
/// "slot": {
/// "$ref": "#/definitions/Slot"
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 64
/// },
/// "expectedVersion": {
/// "$ref": "#/definitions/ExpectedVersion"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "name": {
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// },
/// "profileId": {
/// "$ref": "#/definitions/Ulid"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
pub entries: ::std::vec::Vec<PayloadEntriesItem>,
#[serde(
rename = "expectedVersion",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub expected_version: ::std::option::Option<ExpectedVersion>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub name: PayloadName,
#[serde(
rename = "profileId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub profile_id: ::std::option::Option<Ulid>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///`PayloadContextId`
///
/// <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 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())
})
}
}
///Inline entries only. The `ref`, pinned and override forms of a pool profile are absent from this schema deliberately — a context-local profile that could reference the pool would be a context-authored object acquiring pool reach, which is exactly what the boundary exists to prevent.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Inline entries only. The `ref`, pinned and override forms of a pool profile are absent from this schema deliberately — a context-local profile that could reference the pool would be a context-authored object acquiring pool reach, which is exactly what the boundary exists to prevent.",
/// "type": "object",
/// "required": [
/// "inline"
/// ],
/// "properties": {
/// "inline": {
/// "description": "\nA value the holder keeps in this context and nowhere else.\n\nDeliberately NARROWER than a pool profile's inline entry, which also carries `provenance` and requires it. There is no `provenance` member here, and its absence is a rule rather than an omission: a `credentialBacked` provenance names a `credentialId` and a `claimPath`, and a value authored inside a context has nowhere to put either. So a context-local value is SELF-ASSERTED by construction, and a maintainer MUST present it as such.\n\nThat is the same boundary the missing `ref`, pinned and override forms enforce, one member along. Those stop a context-authored object acquiring pool REACH; this stops it acquiring an issuer's AUTHORITY — asserting that a value is attested when no credential was ever checked, over a value the issuer never saw. A holder who needs a context to present an attested claim binds a pool profile, which is holder-authorized, rather than authoring one here.\n\nAdding a `provenance` member to this object would therefore be a privilege escalation dressed as a convenience, not a gap to fill.",
/// "type": "object",
/// "required": [
/// "type",
/// "value",
/// "valueType"
/// ],
/// "properties": {
/// "label": {
/// "type": "string",
/// "maxLength": 128
/// },
/// "type": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "value": {},
/// "valueType": {
/// "$ref": "#/definitions/ValueType"
/// }
/// },
/// "additionalProperties": false
/// },
/// "slot": {
/// "$ref": "#/definitions/Slot"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PayloadEntriesItem {
pub inline: PayloadEntriesItemInline,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub slot: ::std::option::Option<Slot>,
}
impl PayloadEntriesItem {
pub fn builder() -> builder::PayloadEntriesItem {
Default::default()
}
}
/**
A value the holder keeps in this context and nowhere else.
Deliberately NARROWER than a pool profile's inline entry, which also carries `provenance` and requires it. There is no `provenance` member here, and its absence is a rule rather than an omission: a `credentialBacked` provenance names a `credentialId` and a `claimPath`, and a value authored inside a context has nowhere to put either. So a context-local value is SELF-ASSERTED by construction, and a maintainer MUST present it as such.
That is the same boundary the missing `ref`, pinned and override forms enforce, one member along. Those stop a context-authored object acquiring pool REACH; this stops it acquiring an issuer's AUTHORITY — asserting that a value is attested when no credential was ever checked, over a value the issuer never saw. A holder who needs a context to present an attested claim binds a pool profile, which is holder-authorized, rather than authoring one here.
Adding a `provenance` member to this object would therefore be a privilege escalation dressed as a convenience, not a gap to fill.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "\nA value the holder keeps in this context and nowhere else.\n\nDeliberately NARROWER than a pool profile's inline entry, which also carries `provenance` and requires it. There is no `provenance` member here, and its absence is a rule rather than an omission: a `credentialBacked` provenance names a `credentialId` and a `claimPath`, and a value authored inside a context has nowhere to put either. So a context-local value is SELF-ASSERTED by construction, and a maintainer MUST present it as such.\n\nThat is the same boundary the missing `ref`, pinned and override forms enforce, one member along. Those stop a context-authored object acquiring pool REACH; this stops it acquiring an issuer's AUTHORITY — asserting that a value is attested when no credential was ever checked, over a value the issuer never saw. A holder who needs a context to present an attested claim binds a pool profile, which is holder-authorized, rather than authoring one here.\n\nAdding a `provenance` member to this object would therefore be a privilege escalation dressed as a convenience, not a gap to fill.",
/// "type": "object",
/// "required": [
/// "type",
/// "value",
/// "valueType"
/// ],
/// "properties": {
/// "label": {
/// "type": "string",
/// "maxLength": 128
/// },
/// "type": {
/// "$ref": "#/definitions/ClaimType"
/// },
/// "value": {},
/// "valueType": {
/// "$ref": "#/definitions/ValueType"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PayloadEntriesItemInline {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub label: ::std::option::Option<PayloadEntriesItemInlineLabel>,
#[serde(rename = "type")]
pub type_: ClaimType,
pub value: ::serde_json::Value,
#[serde(rename = "valueType")]
pub value_type: ValueType,
}
impl PayloadEntriesItemInline {
pub fn builder() -> builder::PayloadEntriesItemInline {
Default::default()
}
}
///`PayloadEntriesItemInlineLabel`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 128
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadEntriesItemInlineLabel(::std::string::String);
impl ::std::ops::Deref for PayloadEntriesItemInlineLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadEntriesItemInlineLabel> for ::std::string::String {
fn from(value: PayloadEntriesItemInlineLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadEntriesItemInlineLabel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadEntriesItemInlineLabel {
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 PayloadEntriesItemInlineLabel {
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 PayloadEntriesItemInlineLabel {
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 PayloadEntriesItemInlineLabel {
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())
})
}
}
///`PayloadName`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadName(::std::string::String);
impl ::std::ops::Deref for PayloadName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadName> for ::std::string::String {
fn from(value: PayloadName) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadName {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadName {
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 PayloadName {
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 PayloadName {
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 PayloadName {
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/local/profile/put. Type https://trusttasks.org/spec/persona/local/profile/put/1.0#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to persona/local/profile/put. Type https://trusttasks.org/spec/persona/local/profile/put/1.0#response.",
/// "type": "object",
/// "required": [
/// "created",
/// "profileId",
/// "version"
/// ],
/// "properties": {
/// "correlation": {
/// "description": "Local profiles ARE correlation-indexed, and the naive implementation that skips them loses the guard exactly where a human most needs it: a throwaway identity is precisely where somebody reuses a real value. Indexing them is not a leak — the index is above the boundary, is keyed by a hash, and only the holder can query it.",
/// "type": "object",
/// "required": [
/// "severity"
/// ],
/// "properties": {
/// "matchesPoolValue": {
/// "description": "True when a value here also appears in the holder's pool. The signal that a throwaway is not throwaway.",
/// "type": "boolean"
/// },
/// "severity": {
/// "type": "string",
/// "enum": [
/// "none",
/// "low",
/// "high"
/// ]
/// }
/// },
/// "additionalProperties": false
/// },
/// "created": {
/// "type": "boolean"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "profileId": {
/// "$ref": "#/definitions/Ulid"
/// },
/// "version": {
/// "$ref": "#/definitions/Version"
/// }
/// },
/// "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 correlation: ::std::option::Option<ResponseCorrelation>,
pub created: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(rename = "profileId")]
pub profile_id: Ulid,
pub version: Version,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Local profiles ARE correlation-indexed, and the naive implementation that skips them loses the guard exactly where a human most needs it: a throwaway identity is precisely where somebody reuses a real value. Indexing them is not a leak — the index is above the boundary, is keyed by a hash, and only the holder can query it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Local profiles ARE correlation-indexed, and the naive implementation that skips them loses the guard exactly where a human most needs it: a throwaway identity is precisely where somebody reuses a real value. Indexing them is not a leak — the index is above the boundary, is keyed by a hash, and only the holder can query it.",
/// "type": "object",
/// "required": [
/// "severity"
/// ],
/// "properties": {
/// "matchesPoolValue": {
/// "description": "True when a value here also appears in the holder's pool. The signal that a throwaway is not throwaway.",
/// "type": "boolean"
/// },
/// "severity": {
/// "type": "string",
/// "enum": [
/// "none",
/// "low",
/// "high"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseCorrelation {
///True when a value here also appears in the holder's pool. The signal that a throwaway is not throwaway.
#[serde(
rename = "matchesPoolValue",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub matches_pool_value: ::std::option::Option<bool>,
pub severity: ResponseCorrelationSeverity,
}
impl ResponseCorrelation {
pub fn builder() -> builder::ResponseCorrelation {
Default::default()
}
}
///`ResponseCorrelationSeverity`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "none",
/// "low",
/// "high"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseCorrelationSeverity {
#[serde(rename = "none")]
None,
#[serde(rename = "low")]
Low,
#[serde(rename = "high")]
High,
}
impl ::std::fmt::Display for ResponseCorrelationSeverity {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::None => f.write_str("none"),
Self::Low => f.write_str("low"),
Self::High => f.write_str("high"),
}
}
}
impl ::std::str::FromStr for ResponseCorrelationSeverity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"none" => Ok(Self::None),
"low" => Ok(Self::Low),
"high" => Ok(Self::High),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseCorrelationSeverity {
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 ResponseCorrelationSeverity {
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 ResponseCorrelationSeverity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/**
A role a profile entry plays within its profile, so a consumer can find it without guessing from its claim type. A profile MAY hold several entries of one type — a legal name and a display name, two phone numbers — and only a slot says which answers a given question. Unique within a profile.
Well-known slots:
- `displayName` — what this face calls itself. The entry a consumer renders as the face's name to anyone it is shown to. Distinct from the profile's own `name`, which is the holder's private label and never disclosed.
- `primaryEmail`, `primaryPhone`, `primaryAddress` — the entry to use where a counterparty asks for one of a kind and the profile holds several.
- `avatar` — the image this face presents.
Other values are the holder's or the producer's own and carry no meaning a maintainer interprets.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Slot",
/// "description": "\nA role a profile entry plays within its profile, so a consumer can find it without guessing from its claim type. A profile MAY hold several entries of one type — a legal name and a display name, two phone numbers — and only a slot says which answers a given question. Unique within a profile.\n\nWell-known slots:\n\n- `displayName` — what this face calls itself. The entry a consumer renders as the face's name to anyone it is shown to. Distinct from the profile's own `name`, which is the holder's private label and never disclosed.\n- `primaryEmail`, `primaryPhone`, `primaryAddress` — the entry to use where a counterparty asks for one of a kind and the profile holds several.\n- `avatar` — the image this face presents.\n\nOther values are the holder's or the producer's own and carry no meaning a maintainer interprets.",
/// "type": "string",
/// "pattern": "^[a-z][A-Za-z0-9]{0,31}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Slot(::std::string::String);
impl ::std::ops::Deref for Slot {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Slot> for ::std::string::String {
fn from(value: Slot) -> Self {
value.0
}
}
impl ::std::str::FromStr for Slot {
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-Za-z0-9]{0,31}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][A-Za-z0-9]{0,31}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Slot {
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 Slot {
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 Slot {
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 Slot {
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())
})
}
}
///The JSON shape of `value`, declared so that a consumer can render and compare without guessing. The maintainer validates that `value` agrees with this member and does nothing further: it does NOT validate a phone number against a phone-number grammar. That is a producer's affordance, and a store that grows opinions about the contents of its records eventually blocks its consumer's release.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ValueType",
/// "description": "The JSON shape of `value`, declared so that a consumer can render and compare without guessing. The maintainer validates that `value` agrees with this member and does nothing further: it does NOT validate a phone number against a phone-number grammar. That is a producer's affordance, and a store that grows opinions about the contents of its records eventually blocks its consumer's release.",
/// "type": "string",
/// "enum": [
/// "string",
/// "number",
/// "boolean",
/// "date",
/// "object"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ValueType {
#[serde(rename = "string")]
String,
#[serde(rename = "number")]
Number,
#[serde(rename = "boolean")]
Boolean,
#[serde(rename = "date")]
Date,
#[serde(rename = "object")]
Object,
}
impl ::std::fmt::Display for ValueType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::String => f.write_str("string"),
Self::Number => f.write_str("number"),
Self::Boolean => f.write_str("boolean"),
Self::Date => f.write_str("date"),
Self::Object => f.write_str("object"),
}
}
}
impl ::std::str::FromStr for ValueType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"string" => Ok(Self::String),
"number" => Ok(Self::Number),
"boolean" => Ok(Self::Boolean),
"date" => Ok(Self::Date),
"object" => Ok(Self::Object),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ValueType {
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 ValueType {
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 ValueType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A value of the store's monotonic write counter. Server-assigned; a producer never chooses one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Version",
/// "description": "A value of the store's monotonic write counter. Server-assigned; a producer never chooses one.",
/// "type": "integer",
/// "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Version(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for Version {
type Target = ::std::num::NonZeroU64;
fn deref(&self) -> &::std::num::NonZeroU64 {
&self.0
}
}
impl ::std::convert::From<Version> for ::std::num::NonZeroU64 {
fn from(value: Version) -> Self {
value.0
}
}
impl ::std::convert::From<::std::num::NonZeroU64> for Version {
fn from(value: ::std::num::NonZeroU64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for Version {
type Err = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
Ok(Self(value.parse()?))
}
}
impl ::std::convert::TryFrom<&str> for Version {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for Version {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for Version {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
entries: ::std::result::Result<
::std::vec::Vec<super::PayloadEntriesItem>,
::std::string::String,
>,
expected_version: ::std::result::Result<
::std::option::Option<super::ExpectedVersion>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
name: ::std::result::Result<super::PayloadName, ::std::string::String>,
profile_id:
::std::result::Result<::std::option::Option<super::Ulid>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
context_id: Err("no value supplied for context_id".to_string()),
entries: Err("no value supplied for entries".to_string()),
expected_version: Ok(Default::default()),
ext: Ok(Default::default()),
name: Err("no value supplied for name".to_string()),
profile_id: Ok(Default::default()),
}
}
}
impl Payload {
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<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 entries<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PayloadEntriesItem>>,
T::Error: ::std::fmt::Display,
{
self.entries = value
.try_into()
.map_err(|e| format!("error converting supplied value for entries: {e}"));
self
}
pub fn expected_version<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ExpectedVersion>>,
T::Error: ::std::fmt::Display,
{
self.expected_version = value
.try_into()
.map_err(|e| format!("error converting supplied value for expected_version: {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 name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadName>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn profile_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<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?,
entries: value.entries?,
expected_version: value.expected_version?,
ext: value.ext?,
name: value.name?,
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),
entries: Ok(value.entries),
expected_version: Ok(value.expected_version),
ext: Ok(value.ext),
name: Ok(value.name),
profile_id: Ok(value.profile_id),
}
}
}
#[derive(Clone, Debug)]
pub struct PayloadEntriesItem {
inline: ::std::result::Result<super::PayloadEntriesItemInline, ::std::string::String>,
slot: ::std::result::Result<::std::option::Option<super::Slot>, ::std::string::String>,
}
impl ::std::default::Default for PayloadEntriesItem {
fn default() -> Self {
Self {
inline: Err("no value supplied for inline".to_string()),
slot: Ok(Default::default()),
}
}
}
impl PayloadEntriesItem {
pub fn inline<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadEntriesItemInline>,
T::Error: ::std::fmt::Display,
{
self.inline = value
.try_into()
.map_err(|e| format!("error converting supplied value for inline: {e}"));
self
}
pub fn slot<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Slot>>,
T::Error: ::std::fmt::Display,
{
self.slot = value
.try_into()
.map_err(|e| format!("error converting supplied value for slot: {e}"));
self
}
}
impl ::std::convert::TryFrom<PayloadEntriesItem> for super::PayloadEntriesItem {
type Error = super::error::ConversionError;
fn try_from(
value: PayloadEntriesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
inline: value.inline?,
slot: value.slot?,
})
}
}
impl ::std::convert::From<super::PayloadEntriesItem> for PayloadEntriesItem {
fn from(value: super::PayloadEntriesItem) -> Self {
Self {
inline: Ok(value.inline),
slot: Ok(value.slot),
}
}
}
#[derive(Clone, Debug)]
pub struct PayloadEntriesItemInline {
label: ::std::result::Result<
::std::option::Option<super::PayloadEntriesItemInlineLabel>,
::std::string::String,
>,
type_: ::std::result::Result<super::ClaimType, ::std::string::String>,
value: ::std::result::Result<::serde_json::Value, ::std::string::String>,
value_type: ::std::result::Result<super::ValueType, ::std::string::String>,
}
impl ::std::default::Default for PayloadEntriesItemInline {
fn default() -> Self {
Self {
label: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
value: Err("no value supplied for value".to_string()),
value_type: Err("no value supplied for value_type".to_string()),
}
}
}
impl PayloadEntriesItemInline {
pub fn label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadEntriesItemInlineLabel>>,
T::Error: ::std::fmt::Display,
{
self.label = value
.try_into()
.map_err(|e| format!("error converting supplied value for label: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ClaimType>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
pub fn value<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::serde_json::Value>,
T::Error: ::std::fmt::Display,
{
self.value = value
.try_into()
.map_err(|e| format!("error converting supplied value for value: {e}"));
self
}
pub fn value_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ValueType>,
T::Error: ::std::fmt::Display,
{
self.value_type = value
.try_into()
.map_err(|e| format!("error converting supplied value for value_type: {e}"));
self
}
}
impl ::std::convert::TryFrom<PayloadEntriesItemInline> for super::PayloadEntriesItemInline {
type Error = super::error::ConversionError;
fn try_from(
value: PayloadEntriesItemInline,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
label: value.label?,
type_: value.type_?,
value: value.value?,
value_type: value.value_type?,
})
}
}
impl ::std::convert::From<super::PayloadEntriesItemInline> for PayloadEntriesItemInline {
fn from(value: super::PayloadEntriesItemInline) -> Self {
Self {
label: Ok(value.label),
type_: Ok(value.type_),
value: Ok(value.value),
value_type: Ok(value.value_type),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
correlation: ::std::result::Result<
::std::option::Option<super::ResponseCorrelation>,
::std::string::String,
>,
created: ::std::result::Result<bool, ::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>,
version: ::std::result::Result<super::Version, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
correlation: Ok(Default::default()),
created: Err("no value supplied for created".to_string()),
ext: Ok(Default::default()),
profile_id: Err("no value supplied for profile_id".to_string()),
version: Err("no value supplied for version".to_string()),
}
}
}
impl Response {
pub fn correlation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCorrelation>>,
T::Error: ::std::fmt::Display,
{
self.correlation = value
.try_into()
.map_err(|e| format!("error converting supplied value for correlation: {e}"));
self
}
pub fn created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.created = value
.try_into()
.map_err(|e| format!("error converting supplied value for created: {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
}
pub fn version<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Version>,
T::Error: ::std::fmt::Display,
{
self.version = value
.try_into()
.map_err(|e| format!("error converting supplied value for version: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
correlation: value.correlation?,
created: value.created?,
ext: value.ext?,
profile_id: value.profile_id?,
version: value.version?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
correlation: Ok(value.correlation),
created: Ok(value.created),
ext: Ok(value.ext),
profile_id: Ok(value.profile_id),
version: Ok(value.version),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseCorrelation {
matches_pool_value:
::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
severity: ::std::result::Result<super::ResponseCorrelationSeverity, ::std::string::String>,
}
impl ::std::default::Default for ResponseCorrelation {
fn default() -> Self {
Self {
matches_pool_value: Ok(Default::default()),
severity: Err("no value supplied for severity".to_string()),
}
}
}
impl ResponseCorrelation {
pub fn matches_pool_value<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.matches_pool_value = value.try_into().map_err(|e| {
format!("error converting supplied value for matches_pool_value: {e}")
});
self
}
pub fn severity<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseCorrelationSeverity>,
T::Error: ::std::fmt::Display,
{
self.severity = value
.try_into()
.map_err(|e| format!("error converting supplied value for severity: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseCorrelation> for super::ResponseCorrelation {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseCorrelation,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
matches_pool_value: value.matches_pool_value?,
severity: value.severity?,
})
}
}
impl ::std::convert::From<super::ResponseCorrelation> for ResponseCorrelation {
fn from(value: super::ResponseCorrelation) -> Self {
Self {
matches_pool_value: Ok(value.matches_pool_value),
severity: Ok(value.severity),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/local/profile/put/1.0";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"ClaimType\": {\n \"description\": \"The vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.\\n\\nThe token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.\\n\\nThe `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"pattern\": \"^(x:)?[a-z][a-zA-Z0-9]*(\\\\.[a-z][a-zA-Z0-9]*)*$\",\n \"title\": \"ClaimType\",\n \"type\": \"string\"\n },\n \"ExpectedVersion\": {\n \"description\": \"Optimistic-concurrency precondition. A positive value requires the record's current `version` to equal it exactly; zero means create-only and applies only when no live record exists at the address.\",\n \"minimum\": 0,\n \"title\": \"ExpectedVersion\",\n \"type\": \"integer\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to persona/local/profile/put. Type https://trusttasks.org/spec/persona/local/profile/put/1.0#response.\",\n \"properties\": {\n \"correlation\": {\n \"additionalProperties\": false,\n \"description\": \"Local profiles ARE correlation-indexed, and the naive implementation that skips them loses the guard exactly where a human most needs it: a throwaway identity is precisely where somebody reuses a real value. Indexing them is not a leak — the index is above the boundary, is keyed by a hash, and only the holder can query it.\",\n \"properties\": {\n \"matchesPoolValue\": {\n \"description\": \"True when a value here also appears in the holder's pool. The signal that a throwaway is not throwaway.\",\n \"type\": \"boolean\"\n },\n \"severity\": {\n \"enum\": [\n \"none\",\n \"low\",\n \"high\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"severity\"\n ],\n \"type\": \"object\"\n },\n \"created\": {\n \"type\": \"boolean\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\"\n },\n \"version\": {\n \"$ref\": \"#/$defs/Version\"\n }\n },\n \"required\": [\n \"profileId\",\n \"version\",\n \"created\"\n ],\n \"title\": \"Persona Local Profile Put — response payload\",\n \"type\": \"object\"\n },\n \"Slot\": {\n \"description\": \"A role a profile entry plays within its profile, so a consumer can find it without guessing from its claim type. A profile MAY hold several entries of one type — a legal name and a display name, two phone numbers — and only a slot says which answers a given question. Unique within a profile.\\n\\nWell-known slots:\\n\\n- `displayName` — what this face calls itself. The entry a consumer renders as the face's name to anyone it is shown to. Distinct from the profile's own `name`, which is the holder's private label and never disclosed.\\n- `primaryEmail`, `primaryPhone`, `primaryAddress` — the entry to use where a counterparty asks for one of a kind and the profile holds several.\\n- `avatar` — the image this face presents.\\n\\nOther values are the holder's or the producer's own and carry no meaning a maintainer interprets.\",\n \"pattern\": \"^[a-z][A-Za-z0-9]{0,31}$\",\n \"title\": \"Slot\",\n \"type\": \"string\"\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 \"ValueType\": {\n \"description\": \"The JSON shape of `value`, declared so that a consumer can render and compare without guessing. The maintainer validates that `value` agrees with this member and does nothing further: it does NOT validate a phone number against a phone-number grammar. That is a producer's affordance, and a store that grows opinions about the contents of its records eventually blocks its consumer's release.\",\n \"enum\": [\n \"string\",\n \"number\",\n \"boolean\",\n \"date\",\n \"object\"\n ],\n \"title\": \"ValueType\",\n \"type\": \"string\"\n },\n \"Version\": {\n \"description\": \"A value of the store's monotonic write counter. Server-assigned; a producer never chooses one.\",\n \"minimum\": 1,\n \"title\": \"Version\",\n \"type\": \"integer\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/persona/local/profile/put/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Compose a throwaway profile inside a context, from values supplied here rather than drawn from the holder's pool. Inline entries only: a reference is refused, and that refusal is what keeps the local surface pool-free.\",\n \"properties\": {\n \"contextId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"entries\": {\n \"items\": {\n \"additionalProperties\": false,\n \"description\": \"Inline entries only. The `ref`, pinned and override forms of a pool profile are absent from this schema deliberately — a context-local profile that could reference the pool would be a context-authored object acquiring pool reach, which is exactly what the boundary exists to prevent.\",\n \"properties\": {\n \"inline\": {\n \"additionalProperties\": false,\n \"description\": \"A value the holder keeps in this context and nowhere else.\\n\\nDeliberately NARROWER than a pool profile's inline entry, which also carries `provenance` and requires it. There is no `provenance` member here, and its absence is a rule rather than an omission: a `credentialBacked` provenance names a `credentialId` and a `claimPath`, and a value authored inside a context has nowhere to put either. So a context-local value is SELF-ASSERTED by construction, and a maintainer MUST present it as such.\\n\\nThat is the same boundary the missing `ref`, pinned and override forms enforce, one member along. Those stop a context-authored object acquiring pool REACH; this stops it acquiring an issuer's AUTHORITY — asserting that a value is attested when no credential was ever checked, over a value the issuer never saw. A holder who needs a context to present an attested claim binds a pool profile, which is holder-authorized, rather than authoring one here.\\n\\nAdding a `provenance` member to this object would therefore be a privilege escalation dressed as a convenience, not a gap to fill.\",\n \"properties\": {\n \"label\": {\n \"maxLength\": 128,\n \"type\": \"string\"\n },\n \"type\": {\n \"$ref\": \"#/$defs/ClaimType\"\n },\n \"value\": {},\n \"valueType\": {\n \"$ref\": \"#/$defs/ValueType\"\n }\n },\n \"required\": [\n \"type\",\n \"valueType\",\n \"value\"\n ],\n \"type\": \"object\"\n },\n \"slot\": {\n \"$ref\": \"#/$defs/Slot\"\n }\n },\n \"required\": [\n \"inline\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"expectedVersion\": {\n \"$ref\": \"#/$defs/ExpectedVersion\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"name\": {\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\"\n }\n },\n \"required\": [\n \"contextId\",\n \"name\",\n \"entries\"\n ],\n \"title\": \"Persona Local Profile Put — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/persona/local/profile/put/1.0#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"ClaimType\": {\n \"description\": \"The vocabulary token naming what a value IS — `name.legal`, `phone.mobile`, `address.postal`, `person.birthDate`. Dotted, most-general segment first, so that a consumer with no knowledge of the specific token can still group by its prefix.\\n\\nThe token is the maintainer's own; no external vocabulary is primary. External vocabularies (vCard/jCard, OIDC standard claims, schema.org) are mappings applied at PRESENTATION by a renderer, not at rest, so that a query written in any of them can be matched without the store having to live inside any one of them.\\n\\nThe `x:` prefix is an open extension namespace and is not decoration. The closest prior art — Windows CardSpace's self-issued card — supported exactly fifteen predefined claim types with no extensibility, and that is the specific way it failed the requirement a holder actually has. An `x:` attribute stores, composes, binds and discloses exactly like a known one; it renders generically and matches only an explicit query.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"pattern\": \"^(x:)?[a-z][a-zA-Z0-9]*(\\\\.[a-z][a-zA-Z0-9]*)*$\",\n \"title\": \"ClaimType\",\n \"type\": \"string\"\n },\n \"ExpectedVersion\": {\n \"description\": \"Optimistic-concurrency precondition. A positive value requires the record's current `version` to equal it exactly; zero means create-only and applies only when no live record exists at the address.\",\n \"minimum\": 0,\n \"title\": \"ExpectedVersion\",\n \"type\": \"integer\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to persona/local/profile/put. Type https://trusttasks.org/spec/persona/local/profile/put/1.0#response.\",\n \"properties\": {\n \"correlation\": {\n \"additionalProperties\": false,\n \"description\": \"Local profiles ARE correlation-indexed, and the naive implementation that skips them loses the guard exactly where a human most needs it: a throwaway identity is precisely where somebody reuses a real value. Indexing them is not a leak — the index is above the boundary, is keyed by a hash, and only the holder can query it.\",\n \"properties\": {\n \"matchesPoolValue\": {\n \"description\": \"True when a value here also appears in the holder's pool. The signal that a throwaway is not throwaway.\",\n \"type\": \"boolean\"\n },\n \"severity\": {\n \"enum\": [\n \"none\",\n \"low\",\n \"high\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"severity\"\n ],\n \"type\": \"object\"\n },\n \"created\": {\n \"type\": \"boolean\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\"\n },\n \"version\": {\n \"$ref\": \"#/$defs/Version\"\n }\n },\n \"required\": [\n \"profileId\",\n \"version\",\n \"created\"\n ],\n \"title\": \"Persona Local Profile Put — response payload\",\n \"type\": \"object\"\n },\n \"Slot\": {\n \"description\": \"A role a profile entry plays within its profile, so a consumer can find it without guessing from its claim type. A profile MAY hold several entries of one type — a legal name and a display name, two phone numbers — and only a slot says which answers a given question. Unique within a profile.\\n\\nWell-known slots:\\n\\n- `displayName` — what this face calls itself. The entry a consumer renders as the face's name to anyone it is shown to. Distinct from the profile's own `name`, which is the holder's private label and never disclosed.\\n- `primaryEmail`, `primaryPhone`, `primaryAddress` — the entry to use where a counterparty asks for one of a kind and the profile holds several.\\n- `avatar` — the image this face presents.\\n\\nOther values are the holder's or the producer's own and carry no meaning a maintainer interprets.\",\n \"pattern\": \"^[a-z][A-Za-z0-9]{0,31}$\",\n \"title\": \"Slot\",\n \"type\": \"string\"\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 \"ValueType\": {\n \"description\": \"The JSON shape of `value`, declared so that a consumer can render and compare without guessing. The maintainer validates that `value` agrees with this member and does nothing further: it does NOT validate a phone number against a phone-number grammar. That is a producer's affordance, and a store that grows opinions about the contents of its records eventually blocks its consumer's release.\",\n \"enum\": [\n \"string\",\n \"number\",\n \"boolean\",\n \"date\",\n \"object\"\n ],\n \"title\": \"ValueType\",\n \"type\": \"string\"\n },\n \"Version\": {\n \"description\": \"A value of the store's monotonic write counter. Server-assigned; a producer never chooses one.\",\n \"minimum\": 1,\n \"title\": \"Version\",\n \"type\": \"integer\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::REFERENCE_NOT_PERMITTED,
error_codes::DUPLICATE_SLOT,
];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `persona/local/profile/put:referenceNotPermitted`
///
/// An entry attempted to reference a pool attribute. Local profiles are inline-only, and honouring a reference would let a context-authored object acquire pool reach.
///
/// Declared `retryable: false`.
pub const REFERENCE_NOT_PERMITTED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/local/profile/put:referenceNotPermitted",
retryable: false,
};
/// `persona/local/profile/put:duplicateSlot`
///
/// Two entries carry the same `slot`. The details name the slot. A slot answers one question with one entry, so the profile is not written.
///
/// Declared `retryable: false`.
pub const DUPLICATE_SLOT: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/local/profile/put:duplicateSlot",
retryable: false,
};
}