//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `persona/attribute/promote`. 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())
})
}
}
///Make values a context-local face carries reusable: each named entry's value becomes a pool attribute, and the face — which can no longer live inside one context once it references the pool — moves above contexts, keeping its id and staying worn wherever it was. One-way.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/persona/attribute/promote/1.0",
/// "title": "Payload",
/// "description": "Make values a context-local face carries reusable: each named entry's value becomes a pool attribute, and the face — which can no longer live inside one context once it references the pool — moves above contexts, keeping its id and staying worn wherever it was. One-way.",
/// "type": "object",
/// "required": [
/// "contextId",
/// "entries",
/// "expectedVersion",
/// "profileId"
/// ],
/// "properties": {
/// "contextId": {
/// "description": "The context the local face lives in.",
/// "type": "string",
/// "minLength": 1
/// },
/// "entries": {
/// "description": "Zero-based positions, in the face's `entries`, of the values to promote. Positions are meaningful only against the version the producer read, which is why `expectedVersion` is required.",
/// "type": "array",
/// "items": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "maxItems": 64,
/// "minItems": 1,
/// "uniqueItems": true
/// },
/// "expectedVersion": {
/// "description": "The local face's version as the producer read it. Required: a position into a face edited since would promote a different value than the holder chose.",
/// "$ref": "#/definitions/Version"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "profileId": {
/// "description": "The context-local face.",
/// "$ref": "#/definitions/Ulid"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The context the local face lives in.
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
///Zero-based positions, in the face's `entries`, of the values to promote. Positions are meaningful only against the version the producer read, which is why `expectedVersion` is required.
pub entries: Vec<u64>,
///The local face's version as the producer read it. Required: a position into a face edited since would promote a different value than the holder chose.
#[serde(rename = "expectedVersion")]
pub expected_version: Version,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The context-local face.
#[serde(rename = "profileId")]
pub profile_id: Ulid,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The context the local face lives in.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The context the local face lives in.",
/// "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/attribute/promote. Type https://trusttasks.org/spec/persona/attribute/promote/1.0#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to persona/attribute/promote. Type https://trusttasks.org/spec/persona/attribute/promote/1.0#response.",
/// "type": "object",
/// "required": [
/// "profileId",
/// "promoted",
/// "version"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "profileId": {
/// "description": "Unchanged: the face keeps its id. It is now read through persona/profile/get.",
/// "$ref": "#/definitions/Ulid"
/// },
/// "promoted": {
/// "description": "For each promoted position, in request order, the pool attribute the entry now references and whether this promote created it. `created: false` means the holder already kept exactly this value, and the face now shares it with whatever else presents it.",
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "attributeId",
/// "created",
/// "entry"
/// ],
/// "properties": {
/// "attributeId": {
/// "$ref": "#/definitions/Ulid"
/// },
/// "created": {
/// "type": "boolean"
/// },
/// "entry": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 64,
/// "minItems": 1
/// },
/// "reboundPersonaDids": {
/// "description": "Personas in `contextId` that wore the local face and now wear it from the pool. What they present is unchanged. Absent when none did.",
/// "type": "array",
/// "items": {
/// "type": "string",
/// "minLength": 1
/// },
/// "maxItems": 256
/// },
/// "version": {
/// "description": "The face's version in the pool.",
/// "$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 ext: ::std::option::Option<Ext>,
///Unchanged: the face keeps its id. It is now read through persona/profile/get.
#[serde(rename = "profileId")]
pub profile_id: Ulid,
///For each promoted position, in request order, the pool attribute the entry now references and whether this promote created it. `created: false` means the holder already kept exactly this value, and the face now shares it with whatever else presents it.
pub promoted: ::std::vec::Vec<ResponsePromotedItem>,
///Personas in `contextId` that wore the local face and now wear it from the pool. What they present is unchanged. Absent when none did.
#[serde(
rename = "reboundPersonaDids",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub rebound_persona_dids: ::std::vec::Vec<ResponseReboundPersonaDidsItem>,
///The face's version in the pool.
pub version: Version,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponsePromotedItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "attributeId",
/// "created",
/// "entry"
/// ],
/// "properties": {
/// "attributeId": {
/// "$ref": "#/definitions/Ulid"
/// },
/// "created": {
/// "type": "boolean"
/// },
/// "entry": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponsePromotedItem {
#[serde(rename = "attributeId")]
pub attribute_id: Ulid,
pub created: bool,
pub entry: u64,
}
impl ResponsePromotedItem {
pub fn builder() -> builder::ResponsePromotedItem {
Default::default()
}
}
///`ResponseReboundPersonaDidsItem`
///
/// <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 ResponseReboundPersonaDidsItem(::std::string::String);
impl ::std::ops::Deref for ResponseReboundPersonaDidsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseReboundPersonaDidsItem> for ::std::string::String {
fn from(value: ResponseReboundPersonaDidsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseReboundPersonaDidsItem {
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 ResponseReboundPersonaDidsItem {
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 ResponseReboundPersonaDidsItem {
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 ResponseReboundPersonaDidsItem {
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 ResponseReboundPersonaDidsItem {
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())
})
}
}
///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<Vec<u64>, ::std::string::String>,
expected_version: ::std::result::Result<super::Version, ::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: Err("no value supplied for context_id".to_string()),
entries: Err("no value supplied for entries".to_string()),
expected_version: Err("no value supplied for expected_version".to_string()),
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<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<Vec<u64>>,
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<super::Version>,
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 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?,
entries: value.entries?,
expected_version: value.expected_version?,
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),
entries: Ok(value.entries),
expected_version: Ok(value.expected_version),
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>,
promoted: ::std::result::Result<
::std::vec::Vec<super::ResponsePromotedItem>,
::std::string::String,
>,
rebound_persona_dids: ::std::result::Result<
::std::vec::Vec<super::ResponseReboundPersonaDidsItem>,
::std::string::String,
>,
version: ::std::result::Result<super::Version, ::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()),
promoted: Err("no value supplied for promoted".to_string()),
rebound_persona_dids: Ok(Default::default()),
version: Err("no value supplied for version".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 promoted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponsePromotedItem>>,
T::Error: ::std::fmt::Display,
{
self.promoted = value
.try_into()
.map_err(|e| format!("error converting supplied value for promoted: {e}"));
self
}
pub fn rebound_persona_dids<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseReboundPersonaDidsItem>>,
T::Error: ::std::fmt::Display,
{
self.rebound_persona_dids = value.try_into().map_err(|e| {
format!("error converting supplied value for rebound_persona_dids: {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 {
ext: value.ext?,
profile_id: value.profile_id?,
promoted: value.promoted?,
rebound_persona_dids: value.rebound_persona_dids?,
version: value.version?,
})
}
}
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),
promoted: Ok(value.promoted),
rebound_persona_dids: Ok(value.rebound_persona_dids),
version: Ok(value.version),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponsePromotedItem {
attribute_id: ::std::result::Result<super::Ulid, ::std::string::String>,
created: ::std::result::Result<bool, ::std::string::String>,
entry: ::std::result::Result<u64, ::std::string::String>,
}
impl ::std::default::Default for ResponsePromotedItem {
fn default() -> Self {
Self {
attribute_id: Err("no value supplied for attribute_id".to_string()),
created: Err("no value supplied for created".to_string()),
entry: Err("no value supplied for entry".to_string()),
}
}
}
impl ResponsePromotedItem {
pub fn attribute_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ulid>,
T::Error: ::std::fmt::Display,
{
self.attribute_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for attribute_id: {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 entry<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.entry = value
.try_into()
.map_err(|e| format!("error converting supplied value for entry: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponsePromotedItem> for super::ResponsePromotedItem {
type Error = super::error::ConversionError;
fn try_from(
value: ResponsePromotedItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
attribute_id: value.attribute_id?,
created: value.created?,
entry: value.entry?,
})
}
}
impl ::std::convert::From<super::ResponsePromotedItem> for ResponsePromotedItem {
fn from(value: super::ResponsePromotedItem) -> Self {
Self {
attribute_id: Ok(value.attribute_id),
created: Ok(value.created),
entry: Ok(value.entry),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/attribute/promote/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 \"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/attribute/promote. Type https://trusttasks.org/spec/persona/attribute/promote/1.0#response.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"Unchanged: the face keeps its id. It is now read through persona/profile/get.\"\n },\n \"promoted\": {\n \"description\": \"For each promoted position, in request order, the pool attribute the entry now references and whether this promote created it. `created: false` means the holder already kept exactly this value, and the face now shares it with whatever else presents it.\",\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"attributeId\": {\n \"$ref\": \"#/$defs/Ulid\"\n },\n \"created\": {\n \"type\": \"boolean\"\n },\n \"entry\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"entry\",\n \"attributeId\",\n \"created\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"reboundPersonaDids\": {\n \"description\": \"Personas in `contextId` that wore the local face and now wear it from the pool. What they present is unchanged. Absent when none did.\",\n \"items\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 256,\n \"type\": \"array\"\n },\n \"version\": {\n \"$ref\": \"#/$defs/Version\",\n \"description\": \"The face's version in the pool.\"\n }\n },\n \"required\": [\n \"profileId\",\n \"version\",\n \"promoted\"\n ],\n \"title\": \"Persona Attribute Promote — 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 \"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/attribute/promote/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Make values a context-local face carries reusable: each named entry's value becomes a pool attribute, and the face — which can no longer live inside one context once it references the pool — moves above contexts, keeping its id and staying worn wherever it was. One-way.\",\n \"properties\": {\n \"contextId\": {\n \"description\": \"The context the local face lives in.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"entries\": {\n \"description\": \"Zero-based positions, in the face's `entries`, of the values to promote. Positions are meaningful only against the version the producer read, which is why `expectedVersion` is required.\",\n \"items\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"expectedVersion\": {\n \"$ref\": \"#/$defs/Version\",\n \"description\": \"The local face's version as the producer read it. Required: a position into a face edited since would promote a different value than the holder chose.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"The context-local face.\"\n }\n },\n \"required\": [\n \"contextId\",\n \"profileId\",\n \"entries\",\n \"expectedVersion\"\n ],\n \"title\": \"Persona Attribute Promote — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/persona/attribute/promote/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 \"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/attribute/promote. Type https://trusttasks.org/spec/persona/attribute/promote/1.0#response.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"profileId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"Unchanged: the face keeps its id. It is now read through persona/profile/get.\"\n },\n \"promoted\": {\n \"description\": \"For each promoted position, in request order, the pool attribute the entry now references and whether this promote created it. `created: false` means the holder already kept exactly this value, and the face now shares it with whatever else presents it.\",\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"attributeId\": {\n \"$ref\": \"#/$defs/Ulid\"\n },\n \"created\": {\n \"type\": \"boolean\"\n },\n \"entry\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"entry\",\n \"attributeId\",\n \"created\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"reboundPersonaDids\": {\n \"description\": \"Personas in `contextId` that wore the local face and now wear it from the pool. What they present is unchanged. Absent when none did.\",\n \"items\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 256,\n \"type\": \"array\"\n },\n \"version\": {\n \"$ref\": \"#/$defs/Version\",\n \"description\": \"The face's version in the pool.\"\n }\n },\n \"required\": [\n \"profileId\",\n \"version\",\n \"promoted\"\n ],\n \"title\": \"Persona Attribute Promote — 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 \"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::ENTRY_OUT_OF_RANGE,
error_codes::VERSION_CONFLICT,
];
/// 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/attribute/promote:entryOutOfRange`
///
/// A position is beyond the end of the face's entries. The details carry the face's entry count. Nothing is written.
///
/// Declared `retryable: false`.
pub const ENTRY_OUT_OF_RANGE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/attribute/promote:entryOutOfRange",
retryable: false,
};
/// `persona/attribute/promote:versionConflict`
///
/// The face's version is not `expectedVersion`. Details carry the current version. Nothing is written.
///
/// Declared `retryable: false`.
pub const VERSION_CONFLICT: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/attribute/promote:versionConflict",
retryable: false,
};
}