//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `persona/binding/list`. 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())
})
}
}
///Enumerate the personas present in one context. This context only — an application learns which identities operate where it does, and nothing about anywhere else the holder operates.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/persona/binding/list/1.0",
/// "title": "Payload",
/// "description": "Enumerate the personas present in one context. This context only — an application learns which identities operate where it does, and nothing about anywhere else the holder operates.",
/// "type": "object",
/// "required": [
/// "contextId"
/// ],
/// "properties": {
/// "contextId": {
/// "type": "string",
/// "minLength": 1
/// },
/// "cursor": {
/// "type": "string",
/// "maxLength": 4096
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "limit": {
/// "default": 100,
/// "type": "integer",
/// "maximum": 500.0,
/// "minimum": 1.0
/// }
/// },
/// "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,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<PayloadCursor>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(default = "defaults::default_nzu64::<::std::num::NonZeroU64, 100>")]
pub limit: ::std::num::NonZeroU64,
}
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())
})
}
}
///`PayloadCursor`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 4096
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCursor(::std::string::String);
impl ::std::ops::Deref for PayloadCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCursor> for ::std::string::String {
fn from(value: PayloadCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCursor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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/binding/list. Type https://trusttasks.org/spec/persona/binding/list/1.0#response. Carries the same thin summary as persona/binding/get, for the same reason: an application needs to know which identity is in use, not what it contains.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to persona/binding/list. Type https://trusttasks.org/spec/persona/binding/list/1.0#response. Carries the same thin summary as persona/binding/get, for the same reason: an application needs to know which identity is in use, not what it contains.",
/// "type": "object",
/// "required": [
/// "personas"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "nextCursor": {
/// "type": "string",
/// "maxLength": 4096
/// },
/// "personas": {
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "bound",
/// "personaDid"
/// ],
/// "properties": {
/// "bound": {
/// "type": "boolean"
/// },
/// "claimCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "isLocal": {
/// "description": "True when the bound profile is context-local rather than imported from the holder's pool. Worth surfacing: a local persona is one the application itself may have composed, and an application should be able to tell what it authored from what the holder pushed down.",
/// "type": "boolean"
/// },
/// "personaDid": {
/// "type": "string",
/// "minLength": 1
/// },
/// "profileName": {
/// "description": "The holder's label for the bound profile. Names a composition; reveals none of it.",
/// "type": "string",
/// "maxLength": 128
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 500
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub next_cursor: ::std::option::Option<ResponseNextCursor>,
pub personas: ::std::vec::Vec<ResponsePersonasItem>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseNextCursor`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 4096
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseNextCursor(::std::string::String);
impl ::std::ops::Deref for ResponseNextCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseNextCursor> for ::std::string::String {
fn from(value: ResponseNextCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseNextCursor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
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())
})
}
}
///`ResponsePersonasItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "bound",
/// "personaDid"
/// ],
/// "properties": {
/// "bound": {
/// "type": "boolean"
/// },
/// "claimCount": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "isLocal": {
/// "description": "True when the bound profile is context-local rather than imported from the holder's pool. Worth surfacing: a local persona is one the application itself may have composed, and an application should be able to tell what it authored from what the holder pushed down.",
/// "type": "boolean"
/// },
/// "personaDid": {
/// "type": "string",
/// "minLength": 1
/// },
/// "profileName": {
/// "description": "The holder's label for the bound profile. Names a composition; reveals none of it.",
/// "type": "string",
/// "maxLength": 128
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponsePersonasItem {
pub bound: bool,
#[serde(
rename = "claimCount",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub claim_count: ::std::option::Option<u64>,
///True when the bound profile is context-local rather than imported from the holder's pool. Worth surfacing: a local persona is one the application itself may have composed, and an application should be able to tell what it authored from what the holder pushed down.
#[serde(
rename = "isLocal",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub is_local: ::std::option::Option<bool>,
#[serde(rename = "personaDid")]
pub persona_did: ResponsePersonasItemPersonaDid,
///The holder's label for the bound profile. Names a composition; reveals none of it.
#[serde(
rename = "profileName",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub profile_name: ::std::option::Option<ResponsePersonasItemProfileName>,
}
impl ResponsePersonasItem {
pub fn builder() -> builder::ResponsePersonasItem {
Default::default()
}
}
///`ResponsePersonasItemPersonaDid`
///
/// <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 ResponsePersonasItemPersonaDid(::std::string::String);
impl ::std::ops::Deref for ResponsePersonasItemPersonaDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponsePersonasItemPersonaDid> for ::std::string::String {
fn from(value: ResponsePersonasItemPersonaDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponsePersonasItemPersonaDid {
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 ResponsePersonasItemPersonaDid {
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 ResponsePersonasItemPersonaDid {
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 ResponsePersonasItemPersonaDid {
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 ResponsePersonasItemPersonaDid {
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 holder's label for the bound profile. Names a composition; reveals none of it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The holder's label for the bound profile. Names a composition; reveals none of it.",
/// "type": "string",
/// "maxLength": 128
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponsePersonasItemProfileName(::std::string::String);
impl ::std::ops::Deref for ResponsePersonasItemProfileName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponsePersonasItemProfileName> for ::std::string::String {
fn from(value: ResponsePersonasItemProfileName) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponsePersonasItemProfileName {
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 ResponsePersonasItemProfileName {
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 ResponsePersonasItemProfileName {
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 ResponsePersonasItemProfileName {
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 ResponsePersonasItemProfileName {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
cursor: ::std::result::Result<
::std::option::Option<super::PayloadCursor>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
limit: ::std::result::Result<::std::num::NonZeroU64, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
context_id: Err("no value supplied for context_id".to_string()),
cursor: Ok(Default::default()),
ext: Ok(Default::default()),
limit: Ok(super::defaults::default_nzu64::<::std::num::NonZeroU64, 100>()),
}
}
}
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 cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadCursor>>,
T::Error: ::std::fmt::Display,
{
self.cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for cursor: {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 limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::num::NonZeroU64>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {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?,
cursor: value.cursor?,
ext: value.ext?,
limit: value.limit?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
context_id: Ok(value.context_id),
cursor: Ok(value.cursor),
ext: Ok(value.ext),
limit: Ok(value.limit),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
next_cursor: ::std::result::Result<
::std::option::Option<super::ResponseNextCursor>,
::std::string::String,
>,
personas: ::std::result::Result<
::std::vec::Vec<super::ResponsePersonasItem>,
::std::string::String,
>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
next_cursor: Ok(Default::default()),
personas: Err("no value supplied for personas".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 next_cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseNextCursor>>,
T::Error: ::std::fmt::Display,
{
self.next_cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for next_cursor: {e}"));
self
}
pub fn personas<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponsePersonasItem>>,
T::Error: ::std::fmt::Display,
{
self.personas = value
.try_into()
.map_err(|e| format!("error converting supplied value for personas: {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?,
next_cursor: value.next_cursor?,
personas: value.personas?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
next_cursor: Ok(value.next_cursor),
personas: Ok(value.personas),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponsePersonasItem {
bound: ::std::result::Result<bool, ::std::string::String>,
claim_count: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
is_local: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
persona_did:
::std::result::Result<super::ResponsePersonasItemPersonaDid, ::std::string::String>,
profile_name: ::std::result::Result<
::std::option::Option<super::ResponsePersonasItemProfileName>,
::std::string::String,
>,
}
impl ::std::default::Default for ResponsePersonasItem {
fn default() -> Self {
Self {
bound: Err("no value supplied for bound".to_string()),
claim_count: Ok(Default::default()),
is_local: Ok(Default::default()),
persona_did: Err("no value supplied for persona_did".to_string()),
profile_name: Ok(Default::default()),
}
}
}
impl ResponsePersonasItem {
pub fn bound<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.bound = value
.try_into()
.map_err(|e| format!("error converting supplied value for bound: {e}"));
self
}
pub fn claim_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.claim_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for claim_count: {e}"));
self
}
pub fn is_local<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.is_local = value
.try_into()
.map_err(|e| format!("error converting supplied value for is_local: {e}"));
self
}
pub fn persona_did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponsePersonasItemPersonaDid>,
T::Error: ::std::fmt::Display,
{
self.persona_did = value
.try_into()
.map_err(|e| format!("error converting supplied value for persona_did: {e}"));
self
}
pub fn profile_name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::ResponsePersonasItemProfileName>,
>,
T::Error: ::std::fmt::Display,
{
self.profile_name = value
.try_into()
.map_err(|e| format!("error converting supplied value for profile_name: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponsePersonasItem> for super::ResponsePersonasItem {
type Error = super::error::ConversionError;
fn try_from(
value: ResponsePersonasItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bound: value.bound?,
claim_count: value.claim_count?,
is_local: value.is_local?,
persona_did: value.persona_did?,
profile_name: value.profile_name?,
})
}
}
impl ::std::convert::From<super::ResponsePersonasItem> for ResponsePersonasItem {
fn from(value: super::ResponsePersonasItem) -> Self {
Self {
bound: Ok(value.bound),
claim_count: Ok(value.claim_count),
is_local: Ok(value.is_local),
persona_did: Ok(value.persona_did),
profile_name: Ok(value.profile_name),
}
}
}
}
/// Generation of default values for serde.
pub mod defaults {
pub(super) fn default_nzu64<T, const V: u64>() -> T
where
T: ::std::convert::TryFrom<::std::num::NonZeroU64>,
<T as ::std::convert::TryFrom<::std::num::NonZeroU64>>::Error: ::std::fmt::Debug,
{
T::try_from(::std::num::NonZeroU64::try_from(V).unwrap()).unwrap()
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/binding/list/1.0";
const IS_PROOF_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/binding/list. Type https://trusttasks.org/spec/persona/binding/list/1.0#response. Carries the same thin summary as persona/binding/get, for the same reason: an application needs to know which identity is in use, not what it contains.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"nextCursor\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"personas\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"bound\": {\n \"type\": \"boolean\"\n },\n \"claimCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"isLocal\": {\n \"description\": \"True when the bound profile is context-local rather than imported from the holder's pool. Worth surfacing: a local persona is one the application itself may have composed, and an application should be able to tell what it authored from what the holder pushed down.\",\n \"type\": \"boolean\"\n },\n \"personaDid\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"profileName\": {\n \"description\": \"The holder's label for the bound profile. Names a composition; reveals none of it.\",\n \"maxLength\": 128,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"personaDid\",\n \"bound\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 500,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"personas\"\n ],\n \"title\": \"Persona Binding List — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/persona/binding/list/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Enumerate the personas present in one context. This context only — an application learns which identities operate where it does, and nothing about anywhere else the holder operates.\",\n \"properties\": {\n \"contextId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"cursor\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"limit\": {\n \"default\": 100,\n \"maximum\": 500,\n \"minimum\": 1,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"contextId\"\n ],\n \"title\": \"Persona Binding List — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/binding/list/1.0#response";
const IS_PROOF_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/binding/list. Type https://trusttasks.org/spec/persona/binding/list/1.0#response. Carries the same thin summary as persona/binding/get, for the same reason: an application needs to know which identity is in use, not what it contains.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"nextCursor\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"personas\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"bound\": {\n \"type\": \"boolean\"\n },\n \"claimCount\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"isLocal\": {\n \"description\": \"True when the bound profile is context-local rather than imported from the holder's pool. Worth surfacing: a local persona is one the application itself may have composed, and an application should be able to tell what it authored from what the holder pushed down.\",\n \"type\": \"boolean\"\n },\n \"personaDid\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"profileName\": {\n \"description\": \"The holder's label for the bound profile. Names a composition; reveals none of it.\",\n \"maxLength\": 128,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"personaDid\",\n \"bound\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 500,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"personas\"\n ],\n \"title\": \"Persona Binding List — response payload\",\n \"type\": \"object\"\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;
}