//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/contexts/update`. 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())
}
}
}
///Per-context restrictions the VTA enforces. Every member is optional, and **absence means unrestricted, not empty** — a policy that omits `presentableTypes` permits every type, while one that sets it to `[]` permits none. The two are opposite instructions and a consumer MUST NOT collapse them.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ContextPolicy",
/// "description": "Per-context restrictions the VTA enforces. Every member is optional, and **absence means unrestricted, not empty** — a policy that omits `presentableTypes` permits every type, while one that sets it to `[]` permits none. The two are opposite instructions and a consumer MUST NOT collapse them.",
/// "type": "object",
/// "properties": {
/// "exportAllowed": {
/// "description": "Whether material in this context may leave it through an export. Defaults to true; set it to false for a context whose contents must not be extractable.",
/// "default": true,
/// "type": "boolean"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "presentableTypes": {
/// "description": "Credential types that may be presented from this context. Absent: any type. Present-but-empty: none.",
/// "type": "array",
/// "items": {
/// "type": "string"
/// }
/// },
/// "quotas": {
/// "description": "Resource limits for the context. Shape is maintainer-defined.",
/// "type": "object",
/// "additionalProperties": true
/// },
/// "signableKeys": {
/// "description": "Key ids the signing oracle may be invoked on within this context. Absent: every key the context holds. Present-but-empty: no keys.",
/// "type": "array",
/// "items": {
/// "type": "string"
/// }
/// },
/// "trustedVerifiers": {
/// "description": "VIDs permitted to receive presentations from this context. Absent: any verifier. Present-but-empty: none.",
/// "type": "array",
/// "items": {
/// "type": "string"
/// }
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ContextPolicy {
///Whether material in this context may leave it through an export. Defaults to true; set it to false for a context whose contents must not be extractable.
#[serde(rename = "exportAllowed", default = "defaults::default_bool::<true>")]
pub export_allowed: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Credential types that may be presented from this context. Absent: any type. Present-but-empty: none.
#[serde(
rename = "presentableTypes",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub presentable_types: ::std::vec::Vec<::std::string::String>,
///Resource limits for the context. Shape is maintainer-defined.
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub quotas: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Key ids the signing oracle may be invoked on within this context. Absent: every key the context holds. Present-but-empty: no keys.
#[serde(
rename = "signableKeys",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub signable_keys: ::std::vec::Vec<::std::string::String>,
///VIDs permitted to receive presentations from this context. Absent: any verifier. Present-but-empty: none.
#[serde(
rename = "trustedVerifiers",
default,
skip_serializing_if = "::std::vec::Vec::is_empty"
)]
pub trusted_verifiers: ::std::vec::Vec<::std::string::String>,
}
impl ::std::default::Default for ContextPolicy {
fn default() -> Self {
Self {
export_allowed: defaults::default_bool::<true>(),
ext: Default::default(),
presentable_types: Default::default(),
quotas: Default::default(),
signable_keys: Default::default(),
trusted_verifiers: Default::default(),
}
}
}
///A context as the VTA holds it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ContextRecord",
/// "description": "A context as the VTA holds it.",
/// "type": "object",
/// "required": [
/// "basePath",
/// "createdAt",
/// "id",
/// "name",
/// "updatedAt"
/// ],
/// "properties": {
/// "basePath": {
/// "description": "Resolved path from the root context, as the VTA derives it from the parent chain. Consumers MUST treat this as derived state: it is recomputed by the maintainer and is not independently settable.",
/// "type": "string"
/// },
/// "createdAt": {
/// "description": "RFC 3339.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "description": {
/// "description": "Free-form description.",
/// "type": "string"
/// },
/// "did": {
/// "description": "DID this context acts as, when one has been assigned. Absent means the context has no identity of its own yet — not that it has been denied one.",
/// "type": "string"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "id": {
/// "description": "Context id. For a nested context this is the full path (`parent/leaf`), not the leaf alone — an ACL scope naming this context must use this value verbatim.",
/// "type": "string",
/// "minLength": 1
/// },
/// "name": {
/// "description": "Human-readable name. Operator-facing only; carries no authorization meaning, and two contexts may share a name.",
/// "type": "string",
/// "minLength": 1
/// },
/// "parent": {
/// "description": "Id of the context this one nests under. Absent for a top-level context. Authority granted at a parent reaches its children, so this member is load-bearing for anyone reasoning about scope.",
/// "type": "string"
/// },
/// "updatedAt": {
/// "description": "RFC 3339.",
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ContextRecord {
///Resolved path from the root context, as the VTA derives it from the parent chain. Consumers MUST treat this as derived state: it is recomputed by the maintainer and is not independently settable.
#[serde(rename = "basePath")]
pub base_path: ::std::string::String,
///RFC 3339.
#[serde(rename = "createdAt")]
pub created_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Free-form description.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<::std::string::String>,
///DID this context acts as, when one has been assigned. Absent means the context has no identity of its own yet — not that it has been denied one.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub did: ::std::option::Option<::std::string::String>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Context id. For a nested context this is the full path (`parent/leaf`), not the leaf alone — an ACL scope naming this context must use this value verbatim.
pub id: ContextRecordId,
///Human-readable name. Operator-facing only; carries no authorization meaning, and two contexts may share a name.
pub name: ContextRecordName,
///Id of the context this one nests under. Absent for a top-level context. Authority granted at a parent reaches its children, so this member is load-bearing for anyone reasoning about scope.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub parent: ::std::option::Option<::std::string::String>,
///RFC 3339.
#[serde(rename = "updatedAt")]
pub updated_at: ::chrono::DateTime<::chrono::offset::Utc>,
}
///Context id. For a nested context this is the full path (`parent/leaf`), not the leaf alone — an ACL scope naming this context must use this value verbatim.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Context id. For a nested context this is the full path (`parent/leaf`), not the leaf alone — an ACL scope naming this context must use this value verbatim.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ContextRecordId(::std::string::String);
impl ::std::ops::Deref for ContextRecordId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ContextRecordId> for ::std::string::String {
fn from(value: ContextRecordId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ContextRecordId {
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 ContextRecordId {
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 ContextRecordId {
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 ContextRecordId {
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 ContextRecordId {
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())
})
}
}
///Human-readable name. Operator-facing only; carries no authorization meaning, and two contexts may share a name.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Human-readable name. Operator-facing only; carries no authorization meaning, and two contexts may share a name.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ContextRecordName(::std::string::String);
impl ::std::ops::Deref for ContextRecordName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ContextRecordName> for ::std::string::String {
fn from(value: ContextRecordName) -> Self {
value.0
}
}
impl ::std::str::FromStr for ContextRecordName {
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 ContextRecordName {
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 ContextRecordName {
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 ContextRecordName {
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 ContextRecordName {
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())
})
}
}
///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())
})
}
}
///Request payload for vta/contexts/update. Every member except `id` is optional and omitting one leaves that field unchanged — this is a patch, not a replacement.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/contexts/update/1.0",
/// "title": "Payload",
/// "description": "Request payload for vta/contexts/update. Every member except `id` is optional and omitting one leaves that field unchanged — this is a patch, not a replacement.",
/// "type": "object",
/// "required": [
/// "id"
/// ],
/// "properties": {
/// "contextPolicy": {
/// "description": "Replacement policy for the context. Supplied whole: the members present in the new policy are the policy, and one omitted from it becomes unrestricted rather than retaining its previous value.",
/// "$ref": "#/definitions/ContextPolicy"
/// },
/// "description": {
/// "description": "New description.",
/// "type": "string"
/// },
/// "did": {
/// "description": "DID this context acts as. Prefer vta/contexts/update-did, which is the task named and audited for this change; setting it here is permitted for a maintainer that treats the two as one write.",
/// "type": "string"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "id": {
/// "description": "Context to update. Not itself changeable: an id is what ACL scopes name, so renaming one would silently unhook every grant that referenced it.",
/// "type": "string",
/// "minLength": 1
/// },
/// "name": {
/// "description": "New human-readable name.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Payload {
///Replacement policy for the context. Supplied whole: the members present in the new policy are the policy, and one omitted from it becomes unrestricted rather than retaining its previous value.
#[serde(
rename = "contextPolicy",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub context_policy: ::std::option::Option<ContextPolicy>,
///New description.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<::std::string::String>,
///DID this context acts as. Prefer vta/contexts/update-did, which is the task named and audited for this change; setting it here is permitted for a maintainer that treats the two as one write.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub did: ::std::option::Option<::std::string::String>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Context to update. Not itself changeable: an id is what ACL scopes name, so renaming one would silently unhook every grant that referenced it.
pub id: PayloadId,
///New human-readable name.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<PayloadName>,
}
///Context to update. Not itself changeable: an id is what ACL scopes name, so renaming one would silently unhook every grant that referenced it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Context to update. Not itself changeable: an id is what ACL scopes name, so renaming one would silently unhook every grant that referenced it.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadId(::std::string::String);
impl ::std::ops::Deref for PayloadId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadId> for ::std::string::String {
fn from(value: PayloadId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadId {
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 PayloadId {
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 PayloadId {
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 PayloadId {
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 PayloadId {
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())
})
}
}
///New human-readable name.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "New human-readable name.",
/// "type": "string",
/// "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() < 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 vta/contexts/update: the context as it now stands. Type https://trusttasks.org/spec/vta/contexts/update/1.0#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to vta/contexts/update: the context as it now stands. Type https://trusttasks.org/spec/vta/contexts/update/1.0#response.",
/// "$ref": "#/definitions/ContextRecord",
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Response(pub ContextRecord);
impl ::std::ops::Deref for Response {
type Target = ContextRecord;
fn deref(&self) -> &ContextRecord {
&self.0
}
}
impl ::std::convert::From<Response> for ContextRecord {
fn from(value: Response) -> Self {
value.0
}
}
impl ::std::convert::From<ContextRecord> for Response {
fn from(value: ContextRecord) -> Self {
Self(value)
}
}
/// Generation of default values for serde.
pub mod defaults {
pub(super) fn default_bool<const V: bool>() -> bool {
V
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/contexts/update/1.0";
const IS_PROOF_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"ContextPolicy\": {\n \"additionalProperties\": false,\n \"description\": \"Per-context restrictions the VTA enforces. Every member is optional, and **absence means unrestricted, not empty** — a policy that omits `presentableTypes` permits every type, while one that sets it to `[]` permits none. The two are opposite instructions and a consumer MUST NOT collapse them.\",\n \"properties\": {\n \"exportAllowed\": {\n \"default\": true,\n \"description\": \"Whether material in this context may leave it through an export. Defaults to true; set it to false for a context whose contents must not be extractable.\",\n \"type\": \"boolean\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"presentableTypes\": {\n \"description\": \"Credential types that may be presented from this context. Absent: any type. Present-but-empty: none.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"quotas\": {\n \"additionalProperties\": true,\n \"description\": \"Resource limits for the context. Shape is maintainer-defined.\",\n \"type\": \"object\"\n },\n \"signableKeys\": {\n \"description\": \"Key ids the signing oracle may be invoked on within this context. Absent: every key the context holds. Present-but-empty: no keys.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"trustedVerifiers\": {\n \"description\": \"VIDs permitted to receive presentations from this context. Absent: any verifier. Present-but-empty: none.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n }\n },\n \"title\": \"ContextPolicy\",\n \"type\": \"object\"\n },\n \"ContextRecord\": {\n \"additionalProperties\": false,\n \"description\": \"A context as the VTA holds it.\",\n \"properties\": {\n \"basePath\": {\n \"description\": \"Resolved path from the root context, as the VTA derives it from the parent chain. Consumers MUST treat this as derived state: it is recomputed by the maintainer and is not independently settable.\",\n \"type\": \"string\"\n },\n \"createdAt\": {\n \"description\": \"RFC 3339.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"description\": {\n \"description\": \"Free-form description.\",\n \"type\": \"string\"\n },\n \"did\": {\n \"description\": \"DID this context acts as, when one has been assigned. Absent means the context has no identity of its own yet — not that it has been denied one.\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"id\": {\n \"description\": \"Context id. For a nested context this is the full path (`parent/leaf`), not the leaf alone — an ACL scope naming this context must use this value verbatim.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"name\": {\n \"description\": \"Human-readable name. Operator-facing only; carries no authorization meaning, and two contexts may share a name.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"parent\": {\n \"description\": \"Id of the context this one nests under. Absent for a top-level context. Authority granted at a parent reaches its children, so this member is load-bearing for anyone reasoning about scope.\",\n \"type\": \"string\"\n },\n \"updatedAt\": {\n \"description\": \"RFC 3339.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"name\",\n \"basePath\",\n \"createdAt\",\n \"updatedAt\"\n ],\n \"title\": \"ContextRecord\",\n \"type\": \"object\"\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 \"$ref\": \"#/$defs/ContextRecord\",\n \"description\": \"Success response to vta/contexts/update: the context as it now stands. Type https://trusttasks.org/spec/vta/contexts/update/1.0#response.\",\n \"title\": \"VTA Contexts Update — response payload\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vta/contexts/update/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Request payload for vta/contexts/update. Every member except `id` is optional and omitting one leaves that field unchanged — this is a patch, not a replacement.\",\n \"properties\": {\n \"contextPolicy\": {\n \"$ref\": \"#/$defs/ContextPolicy\",\n \"description\": \"Replacement policy for the context. Supplied whole: the members present in the new policy are the policy, and one omitted from it becomes unrestricted rather than retaining its previous value.\"\n },\n \"description\": {\n \"description\": \"New description.\",\n \"type\": \"string\"\n },\n \"did\": {\n \"description\": \"DID this context acts as. Prefer vta/contexts/update-did, which is the task named and audited for this change; setting it here is permitted for a maintainer that treats the two as one write.\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"id\": {\n \"description\": \"Context to update. Not itself changeable: an id is what ACL scopes name, so renaming one would silently unhook every grant that referenced it.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"name\": {\n \"description\": \"New human-readable name.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\"\n ],\n \"title\": \"VTA Contexts Update — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/contexts/update/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 \"ContextPolicy\": {\n \"additionalProperties\": false,\n \"description\": \"Per-context restrictions the VTA enforces. Every member is optional, and **absence means unrestricted, not empty** — a policy that omits `presentableTypes` permits every type, while one that sets it to `[]` permits none. The two are opposite instructions and a consumer MUST NOT collapse them.\",\n \"properties\": {\n \"exportAllowed\": {\n \"default\": true,\n \"description\": \"Whether material in this context may leave it through an export. Defaults to true; set it to false for a context whose contents must not be extractable.\",\n \"type\": \"boolean\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"presentableTypes\": {\n \"description\": \"Credential types that may be presented from this context. Absent: any type. Present-but-empty: none.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"quotas\": {\n \"additionalProperties\": true,\n \"description\": \"Resource limits for the context. Shape is maintainer-defined.\",\n \"type\": \"object\"\n },\n \"signableKeys\": {\n \"description\": \"Key ids the signing oracle may be invoked on within this context. Absent: every key the context holds. Present-but-empty: no keys.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"trustedVerifiers\": {\n \"description\": \"VIDs permitted to receive presentations from this context. Absent: any verifier. Present-but-empty: none.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n }\n },\n \"title\": \"ContextPolicy\",\n \"type\": \"object\"\n },\n \"ContextRecord\": {\n \"additionalProperties\": false,\n \"description\": \"A context as the VTA holds it.\",\n \"properties\": {\n \"basePath\": {\n \"description\": \"Resolved path from the root context, as the VTA derives it from the parent chain. Consumers MUST treat this as derived state: it is recomputed by the maintainer and is not independently settable.\",\n \"type\": \"string\"\n },\n \"createdAt\": {\n \"description\": \"RFC 3339.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"description\": {\n \"description\": \"Free-form description.\",\n \"type\": \"string\"\n },\n \"did\": {\n \"description\": \"DID this context acts as, when one has been assigned. Absent means the context has no identity of its own yet — not that it has been denied one.\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"id\": {\n \"description\": \"Context id. For a nested context this is the full path (`parent/leaf`), not the leaf alone — an ACL scope naming this context must use this value verbatim.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"name\": {\n \"description\": \"Human-readable name. Operator-facing only; carries no authorization meaning, and two contexts may share a name.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"parent\": {\n \"description\": \"Id of the context this one nests under. Absent for a top-level context. Authority granted at a parent reaches its children, so this member is load-bearing for anyone reasoning about scope.\",\n \"type\": \"string\"\n },\n \"updatedAt\": {\n \"description\": \"RFC 3339.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"name\",\n \"basePath\",\n \"createdAt\",\n \"updatedAt\"\n ],\n \"title\": \"ContextRecord\",\n \"type\": \"object\"\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 \"$ref\": \"#/$defs/ContextRecord\",\n \"description\": \"Success response to vta/contexts/update: the context as it now stands. Type https://trusttasks.org/spec/vta/contexts/update/1.0#response.\",\n \"title\": \"VTA Contexts Update — response payload\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
#[test]
fn request_example_1() {
const JSON: &str = "{\n \"id\": \"3c4d5e6f-7081-492a-b3c4-d5e6f7081920\",\n \"type\": \"https://trusttasks.org/spec/vta/contexts/update/1.0\",\n \"issuer\": \"did:key:z6MkSuperAdmin\",\n \"recipient\": \"did:web:vta.example\",\n \"issuedAt\": \"2026-08-19T09:30:00Z\",\n \"payload\": {\n \"id\": \"personal/banking\",\n \"description\": \"Accounts, payment credentials and mandates\",\n \"contextPolicy\": {\n \"trustedVerifiers\": [\"did:web:bank.example\", \"did:web:broker.example\"],\n \"exportAllowed\": false\n }\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"created\": \"2026-08-19T09:30:00Z\",\n \"verificationMethod\": \"did:key:z6MkSuperAdmin#z6MkSuperAdmin\",\n \"proofPurpose\": \"assertionMethod\",\n \"proofValue\": \"z58Gh...\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn response_example_1() {
const JSON: &str = "{\n \"id\": \"4d5e6f70-8192-4a3b-c4d5-e6f708192a3b\",\n \"type\": \"https://trusttasks.org/spec/vta/contexts/update/1.0#response\",\n \"issuer\": \"did:web:vta.example\",\n \"recipient\": \"did:key:z6MkSuperAdmin\",\n \"issuedAt\": \"2026-08-19T09:30:01Z\",\n \"threadId\": \"3c4d5e6f-7081-492a-b3c4-d5e6f7081920\",\n \"payload\": {\n \"id\": \"personal/banking\",\n \"name\": \"Banking\",\n \"description\": \"Accounts, payment credentials and mandates\",\n \"parent\": \"personal\",\n \"basePath\": \"personal/banking\",\n \"createdAt\": \"2026-03-11T08:30:00Z\",\n \"updatedAt\": \"2026-08-19T09:30:01Z\"\n }\n}\n";
let doc: crate::TrustTask<super::Response> =
serde_json::from_str(JSON).expect("deserialize response example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "response example failed round-trip");
}
}