//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/backup/initiate-export`. Version: `1.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///The control-plane account of a bundle transfer: which algorithm, on what terms, until when. Exactly one of the two shapes — they are mutually exclusive, since StreamDescriptor requires `transportUrl` and `transportToken` and forbids `chunks`, and ChunkedDescriptor requires `chunks` and forbids both.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BundleDescriptor",
/// "description": "The control-plane account of a bundle transfer: which algorithm, on what terms, until when. Exactly one of the two shapes — they are mutually exclusive, since StreamDescriptor requires `transportUrl` and `transportToken` and forbids `chunks`, and ChunkedDescriptor requires `chunks` and forbids both.",
/// "oneOf": [
/// {
/// "$ref": "#/definitions/StreamDescriptor"
/// },
/// {
/// "$ref": "#/definitions/ChunkedDescriptor"
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
#[non_exhaustive]
pub enum BundleDescriptor {
StreamDescriptor(StreamDescriptor),
ChunkedDescriptor(ChunkedDescriptor),
}
impl ::std::convert::From<StreamDescriptor> for BundleDescriptor {
fn from(value: StreamDescriptor) -> Self {
Self::StreamDescriptor(value)
}
}
impl ::std::convert::From<ChunkedDescriptor> for BundleDescriptor {
fn from(value: ChunkedDescriptor) -> Self {
Self::ChunkedDescriptor(value)
}
}
///Handle for a bundle across its whole lifecycle. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence. Opaque: a producer quotes what it was given and must not derive, guess or enumerate one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BundleId",
/// "description": "Handle for a bundle across its whole lifecycle. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence. Opaque: a producer quotes what it was given and must not derive, guess or enumerate one.",
/// "type": "string",
/// "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BundleId(::std::string::String);
impl ::std::ops::Deref for BundleId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<BundleId> for ::std::string::String {
fn from(value: BundleId) -> Self {
value.0
}
}
impl ::std::str::FromStr for BundleId {
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-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
)
.unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for BundleId {
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 BundleId {
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 BundleId {
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 BundleId {
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())
})
}
}
///Number of chunks in the bundle, equal to ceil(expectedSizeBytes / chunkSize). Bounded at 4096 so that the manifest itself — one digest per chunk — fits in the single document that carries it under the same message-size reasoning as a chunk.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ChunkCount",
/// "description": "Number of chunks in the bundle, equal to ceil(expectedSizeBytes / chunkSize). Bounded at 4096 so that the manifest itself — one digest per chunk — fits in the single document that carries it under the same message-size reasoning as a chunk.",
/// "type": "integer",
/// "maximum": 4096.0,
/// "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ChunkCount(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for ChunkCount {
type Target = ::std::num::NonZeroU64;
fn deref(&self) -> &::std::num::NonZeroU64 {
&self.0
}
}
impl ::std::convert::From<ChunkCount> for ::std::num::NonZeroU64 {
fn from(value: ChunkCount) -> Self {
value.0
}
}
impl ::std::convert::From<::std::num::NonZeroU64> for ChunkCount {
fn from(value: ::std::num::NonZeroU64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for ChunkCount {
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 ChunkCount {
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 ChunkCount {
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 ChunkCount {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
/**
The terms of a `chunkedTrustTask` transfer, committed before any chunk moves. On export the recipient states them in the descriptor; on import the producer pre-commits them in the request and the recipient echoes them. Either way the manifest arrives in a document whose proof is REQUIRED, so the per-chunk digests are authenticated by the party that computed them and each chunk can be verified — and a single bad chunk re-fetched or refused — on arrival rather than only after reassembly.
Consistency rules JSON Schema cannot state: `chunkCount` MUST equal ceil(expectedSizeBytes / chunkSize) for the bundle the manifest describes, and `chunkDigests` MUST have exactly `chunkCount` items. A party receiving a manifest violating either MUST refuse it.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ChunkManifest",
/// "description": "\nThe terms of a `chunkedTrustTask` transfer, committed before any chunk moves. On export the recipient states them in the descriptor; on import the producer pre-commits them in the request and the recipient echoes them. Either way the manifest arrives in a document whose proof is REQUIRED, so the per-chunk digests are authenticated by the party that computed them and each chunk can be verified — and a single bad chunk re-fetched or refused — on arrival rather than only after reassembly.\n\nConsistency rules JSON Schema cannot state: `chunkCount` MUST equal ceil(expectedSizeBytes / chunkSize) for the bundle the manifest describes, and `chunkDigests` MUST have exactly `chunkCount` items. A party receiving a manifest violating either MUST refuse it.",
/// "type": "object",
/// "required": [
/// "chunkCount",
/// "chunkDigests",
/// "chunkSize"
/// ],
/// "properties": {
/// "chunkCount": {
/// "$ref": "#/definitions/ChunkCount"
/// },
/// "chunkDigests": {
/// "description": "Digest of each chunk's raw bytes (not of its base64url encoding), in index order. Compared as decoded multihash bytes, never as encoded strings. sha2-256 is RECOMMENDED and MUST be implemented by every party; a party that does not implement the hash a digest names MUST treat the manifest as unverifiable rather than skip the check.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "maxItems": 4096,
/// "minItems": 1
/// },
/// "chunkSize": {
/// "$ref": "#/definitions/ChunkSize"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ChunkManifest {
#[serde(rename = "chunkCount")]
pub chunk_count: ChunkCount,
///Digest of each chunk's raw bytes (not of its base64url encoding), in index order. Compared as decoded multihash bytes, never as encoded strings. sha2-256 is RECOMMENDED and MUST be implemented by every party; a party that does not implement the hash a digest names MUST treat the manifest as unverifiable rather than skip the check.
#[serde(rename = "chunkDigests")]
pub chunk_digests: ::std::vec::Vec<DigestMultibase>,
#[serde(rename = "chunkSize")]
pub chunk_size: ChunkSize,
}
impl ChunkManifest {
pub fn builder() -> builder::ChunkManifest {
Default::default()
}
}
///Size in bytes of every chunk except the last, which carries the remainder and is between 1 and this value inclusive. The ceiling of 262144 (256 KiB) is normative and is derived in `vta/backup/initiate-export/1.1` under Chunked transfer: it is the largest power of two whose `get-chunk` or `put-chunk` document still fits a 1 MiB mediator message after base64url encoding of `data`, DIDComm authcrypt encoding, and two nested forward wrappers. The floor of 16384 keeps a 1 GiB bundle within `ChunkCount`'s ceiling at sizes a constrained transport can still choose.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ChunkSize",
/// "description": "Size in bytes of every chunk except the last, which carries the remainder and is between 1 and this value inclusive. The ceiling of 262144 (256 KiB) is normative and is derived in `vta/backup/initiate-export/1.1` under Chunked transfer: it is the largest power of two whose `get-chunk` or `put-chunk` document still fits a 1 MiB mediator message after base64url encoding of `data`, DIDComm authcrypt encoding, and two nested forward wrappers. The floor of 16384 keeps a 1 GiB bundle within `ChunkCount`'s ceiling at sizes a constrained transport can still choose.",
/// "type": "integer",
/// "maximum": 262144.0,
/// "minimum": 16384.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ChunkSize(pub i64);
impl ::std::ops::Deref for ChunkSize {
type Target = i64;
fn deref(&self) -> &i64 {
&self.0
}
}
impl ::std::convert::From<ChunkSize> for i64 {
fn from(value: ChunkSize) -> Self {
value.0
}
}
impl ::std::convert::From<i64> for ChunkSize {
fn from(value: i64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for ChunkSize {
type Err = <i64 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 ChunkSize {
type Error = <i64 as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for ChunkSize {
type Error = <i64 as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for ChunkSize {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
///A descriptor for the `chunkedTrustTask` algorithm. Carries no address and no bearer token: every chunk moves in a Trust Task document whose sender the transport authenticates, so possession of a token would add nothing and would be one more secret to leak.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ChunkedDescriptor",
/// "description": "A descriptor for the `chunkedTrustTask` algorithm. Carries no address and no bearer token: every chunk moves in a Trust Task document whose sender the transport authenticates, so possession of a token would add nothing and would be one more secret to leak.",
/// "type": "object",
/// "required": [
/// "algorithm",
/// "bundleId",
/// "chunks",
/// "expectedSha256",
/// "expectedSizeBytes",
/// "expiresAt"
/// ],
/// "properties": {
/// "algorithm": {
/// "description": "Discriminates this shape from StreamDescriptor.",
/// "type": "string",
/// "enum": [
/// "chunkedTrustTask"
/// ]
/// },
/// "bundleId": {
/// "$ref": "#/definitions/BundleId"
/// },
/// "chunks": {
/// "$ref": "#/definitions/ChunkManifest"
/// },
/// "expectedSha256": {
/// "$ref": "#/definitions/ExpectedSha256"
/// },
/// "expectedSizeBytes": {
/// "$ref": "#/definitions/ExpectedSizeBytes"
/// },
/// "expiresAt": {
/// "$ref": "#/definitions/ExpiresAt"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ChunkedDescriptor {
///Discriminates this shape from StreamDescriptor.
pub algorithm: ChunkedDescriptorAlgorithm,
#[serde(rename = "bundleId")]
pub bundle_id: BundleId,
pub chunks: ChunkManifest,
#[serde(rename = "expectedSha256")]
pub expected_sha256: ExpectedSha256,
#[serde(rename = "expectedSizeBytes")]
pub expected_size_bytes: ExpectedSizeBytes,
#[serde(rename = "expiresAt")]
pub expires_at: ExpiresAt,
}
impl ChunkedDescriptor {
pub fn builder() -> builder::ChunkedDescriptor {
Default::default()
}
}
///Discriminates this shape from StreamDescriptor.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Discriminates this shape from StreamDescriptor.",
/// "type": "string",
/// "enum": [
/// "chunkedTrustTask"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ChunkedDescriptorAlgorithm {
#[serde(rename = "chunkedTrustTask")]
ChunkedTrustTask,
}
impl ::std::fmt::Display for ChunkedDescriptorAlgorithm {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::ChunkedTrustTask => f.write_str("chunkedTrustTask"),
}
}
}
impl ::std::str::FromStr for ChunkedDescriptorAlgorithm {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"chunkedTrustTask" => Ok(Self::ChunkedTrustTask),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ChunkedDescriptorAlgorithm {
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 ChunkedDescriptorAlgorithm {
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 ChunkedDescriptorAlgorithm {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/**
A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.
Multihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.
This definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.
Restricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that "interoperability is not guaranteed between implementations using such values", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DigestMultibase",
/// "description": "\nA cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\n\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\n\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\n\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \"interoperability is not guaranteed between implementations using such values\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.",
/// "examples": [
/// "zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"
/// ],
/// "type": "string",
/// "minLength": 16,
/// "pattern": "^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DigestMultibase(::std::string::String);
impl ::std::ops::Deref for DigestMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DigestMultibase> for ::std::string::String {
fn from(value: DigestMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for DigestMultibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 16usize {
return Err("shorter than 16 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\"".into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DigestMultibase {
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 DigestMultibase {
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 DigestMultibase {
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 DigestMultibase {
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())
})
}
}
///Lowercase hex SHA-256 of the whole bundle's bytes. Kept in the hex form the 1.0 descriptor published rather than moved to DigestMultibase, because it is an unchanged member of an existing descriptor and re-encoding it would break every stream producer for no gain in what it checks. For a chunked transfer it is the check over the reassembled bundle, applied after every chunk has verified individually, so that a correct set of chunks assembled in the wrong order is still caught.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ExpectedSha256",
/// "description": "Lowercase hex SHA-256 of the whole bundle's bytes. Kept in the hex form the 1.0 descriptor published rather than moved to DigestMultibase, because it is an unchanged member of an existing descriptor and re-encoding it would break every stream producer for no gain in what it checks. For a chunked transfer it is the check over the reassembled bundle, applied after every chunk has verified individually, so that a correct set of chunks assembled in the wrong order is still caught.",
/// "type": "string",
/// "pattern": "^[0-9a-f]{64}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExpectedSha256(::std::string::String);
impl ::std::ops::Deref for ExpectedSha256 {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExpectedSha256> for ::std::string::String {
fn from(value: ExpectedSha256) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExpectedSha256 {
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-f]{64}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[0-9a-f]{64}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExpectedSha256 {
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 ExpectedSha256 {
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 ExpectedSha256 {
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 ExpectedSha256 {
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())
})
}
}
///Total byte count of the bundle. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ExpectedSizeBytes",
/// "description": "Total byte count of the bundle. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.",
/// "type": "integer",
/// "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ExpectedSizeBytes(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for ExpectedSizeBytes {
type Target = ::std::num::NonZeroU64;
fn deref(&self) -> &::std::num::NonZeroU64 {
&self.0
}
}
impl ::std::convert::From<ExpectedSizeBytes> for ::std::num::NonZeroU64 {
fn from(value: ExpectedSizeBytes) -> Self {
value.0
}
}
impl ::std::convert::From<::std::num::NonZeroU64> for ExpectedSizeBytes {
fn from(value: ::std::num::NonZeroU64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for ExpectedSizeBytes {
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 ExpectedSizeBytes {
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 ExpectedSizeBytes {
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 ExpectedSizeBytes {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
///After which the bundle is collected: staged bytes discarded, tokens and chunk requests refused. Short by design. For a chunked transfer a recipient may move it later as chunks are exchanged, never past its own ceiling — each chunk response reports the current value.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ExpiresAt",
/// "description": "After which the bundle is collected: staged bytes discarded, tokens and chunk requests refused. Short by design. For a chunked transfer a recipient may move it later as chunks are exchanged, never past its own ceiling — each chunk response reports the current value.",
/// "type": "string",
/// "format": "date-time"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ExpiresAt(pub ::chrono::DateTime<::chrono::offset::Utc>);
impl ::std::ops::Deref for ExpiresAt {
type Target = ::chrono::DateTime<::chrono::offset::Utc>;
fn deref(&self) -> &::chrono::DateTime<::chrono::offset::Utc> {
&self.0
}
}
impl ::std::convert::From<ExpiresAt> for ::chrono::DateTime<::chrono::offset::Utc> {
fn from(value: ExpiresAt) -> Self {
value.0
}
}
impl ::std::convert::From<::chrono::DateTime<::chrono::offset::Utc>> for ExpiresAt {
fn from(value: ::chrono::DateTime<::chrono::offset::Utc>) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for ExpiresAt {
type Err = <::chrono::DateTime<::chrono::offset::Utc> 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 ExpiresAt {
type Error = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for ExpiresAt {
type Error = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for ExpiresAt {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Asks the recipient to serialize its entire state into a password-encrypted bundle and return the descriptor that fetches it — by an HTTPS address (`stream`) or chunk by chunk over Trust Task documents (`chunkedTrustTask`). The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/backup/initiate-export/1.1",
/// "title": "Payload",
/// "description": "Asks the recipient to serialize its entire state into a password-encrypted bundle and return the descriptor that fetches it — by an HTTPS address (`stream`) or chunk by chunk over Trust Task documents (`chunkedTrustTask`). The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.",
/// "type": "object",
/// "required": [
/// "password"
/// ],
/// "properties": {
/// "algorithm": {
/// "description": "Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (one HTTPS transfer; what an absent member means) and `chunkedTrustTask` (a sequence of get-chunk tasks over the transport already carrying this one). Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "includeAudit": {
/// "description": "Serialize the audit trail alongside the operational state. Absent means false — stated in prose rather than as a schema `default`, because a materialised default turns an omitted member into an asserted one in generated bindings, which is a different document.",
/// "type": "boolean"
/// },
/// "maxChunkSize": {
/// "description": "For `chunkedTrustTask` only: the largest chunk the producer can receive, for a producer whose transport is tighter than the one the normative ceiling assumes. The recipient chooses a chunkSize no larger than this. Absent means the normative ceiling. Meaningless for any other algorithm, and a recipient ignores it there.",
/// "$ref": "#/definitions/ChunkSize"
/// },
/// "password": {
/// "description": "Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.",
/// "writeOnly": true,
/// "type": "string",
/// "maxLength": 1024,
/// "minLength": 15,
/// "$comment": "No `format: password` — the annotation is advisory in 2020-12 and says less than writeOnly does. No example value anywhere in this directory: a specimen password is the one thing implementers copy."
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (one HTTPS transfer; what an absent member means) and `chunkedTrustTask` (a sequence of get-chunk tasks over the transport already carrying this one). Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub algorithm: ::std::option::Option<PayloadAlgorithm>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Serialize the audit trail alongside the operational state. Absent means false — stated in prose rather than as a schema `default`, because a materialised default turns an omitted member into an asserted one in generated bindings, which is a different document.
#[serde(
rename = "includeAudit",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub include_audit: ::std::option::Option<bool>,
///For `chunkedTrustTask` only: the largest chunk the producer can receive, for a producer whose transport is tighter than the one the normative ceiling assumes. The recipient chooses a chunkSize no larger than this. Absent means the normative ceiling. Meaningless for any other algorithm, and a recipient ignores it there.
#[serde(
rename = "maxChunkSize",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub max_chunk_size: ::std::option::Option<ChunkSize>,
///Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.
pub password: PayloadPassword,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (one HTTPS transfer; what an absent member means) and `chunkedTrustTask` (a sequence of get-chunk tasks over the transport already carrying this one). Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (one HTTPS transfer; what an absent member means) and `chunkedTrustTask` (a sequence of get-chunk tasks over the transport already carrying this one). Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadAlgorithm(::std::string::String);
impl ::std::ops::Deref for PayloadAlgorithm {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadAlgorithm> for ::std::string::String {
fn from(value: PayloadAlgorithm) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadAlgorithm {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadAlgorithm {
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 PayloadAlgorithm {
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 PayloadAlgorithm {
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 PayloadAlgorithm {
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())
})
}
}
///Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.",
/// "writeOnly": true,
/// "type": "string",
/// "maxLength": 1024,
/// "minLength": 15,
/// "$comment": "No `format: password` — the annotation is advisory in 2020-12 and says less than writeOnly does. No example value anywhere in this directory: a specimen password is the one thing implementers copy."
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadPassword(::std::string::String);
impl ::std::ops::Deref for PayloadPassword {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadPassword> for ::std::string::String {
fn from(value: PayloadPassword) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadPassword {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
if value.chars().count() < 15usize {
return Err("shorter than 15 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadPassword {
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 PayloadPassword {
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 PayloadPassword {
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 PayloadPassword {
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())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "descriptor"
/// ],
/// "properties": {
/// "completionHint": {
/// "description": "Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.",
/// "type": "string",
/// "maxLength": 1024
/// },
/// "descriptor": {
/// "description": "Where the bytes are, or how they are divided, what they should be, and until when.",
/// "$ref": "#/definitions/BundleDescriptor"
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.
#[serde(
rename = "completionHint",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub completion_hint: ::std::option::Option<ResponseCompletionHint>,
///Where the bytes are, or how they are divided, what they should be, and until when.
pub descriptor: BundleDescriptor,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.",
/// "type": "string",
/// "maxLength": 1024
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseCompletionHint(::std::string::String);
impl ::std::ops::Deref for ResponseCompletionHint {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseCompletionHint> for ::std::string::String {
fn from(value: ResponseCompletionHint) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseCompletionHint {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseCompletionHint {
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 ResponseCompletionHint {
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 ResponseCompletionHint {
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 ResponseCompletionHint {
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 descriptor for a transfer that happens outside Trust Task documents, at an address the recipient publishes — the `stream` algorithm, and any other algorithm a recipient offers that is shaped as an address plus a bearer credential. Identical in members to the `vta/backup/*/1.0` descriptor.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "StreamDescriptor",
/// "description": "A descriptor for a transfer that happens outside Trust Task documents, at an address the recipient publishes — the `stream` algorithm, and any other algorithm a recipient offers that is shaped as an address plus a bearer credential. Identical in members to the `vta/backup/*/1.0` descriptor.",
/// "type": "object",
/// "required": [
/// "algorithm",
/// "bundleId",
/// "expectedSha256",
/// "expectedSizeBytes",
/// "expiresAt",
/// "transportToken",
/// "transportUrl"
/// ],
/// "properties": {
/// "algorithm": {
/// "description": "The mechanism in use. Never `chunkedTrustTask`, which has its own descriptor shape; a descriptor naming it with a transport address is malformed.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
/// },
/// "bundleId": {
/// "$ref": "#/definitions/BundleId"
/// },
/// "expectedSha256": {
/// "$ref": "#/definitions/ExpectedSha256"
/// },
/// "expectedSizeBytes": {
/// "$ref": "#/definitions/ExpectedSizeBytes"
/// },
/// "expiresAt": {
/// "$ref": "#/definitions/ExpiresAt"
/// },
/// "transportToken": {
/// "description": "Bearer credential for transportUrl, presented in the X-Backup-Token header. Minted per bundle and never reused. A recipient should store only a hash of it, and should accept an export token once.",
/// "type": "string",
/// "maxLength": 1024,
/// "minLength": 1
/// },
/// "transportUrl": {
/// "description": "Where to fetch (export) or write (import) the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unusable one. An import address is write-only: staged bytes are never served back from it.",
/// "type": "string",
/// "format": "uri",
/// "maxLength": 2048
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct StreamDescriptor {
///The mechanism in use. Never `chunkedTrustTask`, which has its own descriptor shape; a descriptor naming it with a transport address is malformed.
pub algorithm: StreamDescriptorAlgorithm,
#[serde(rename = "bundleId")]
pub bundle_id: BundleId,
#[serde(rename = "expectedSha256")]
pub expected_sha256: ExpectedSha256,
#[serde(rename = "expectedSizeBytes")]
pub expected_size_bytes: ExpectedSizeBytes,
#[serde(rename = "expiresAt")]
pub expires_at: ExpiresAt,
///Bearer credential for transportUrl, presented in the X-Backup-Token header. Minted per bundle and never reused. A recipient should store only a hash of it, and should accept an export token once.
#[serde(rename = "transportToken")]
pub transport_token: StreamDescriptorTransportToken,
///Where to fetch (export) or write (import) the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unusable one. An import address is write-only: staged bytes are never served back from it.
#[serde(rename = "transportUrl")]
pub transport_url: ::std::string::String,
}
impl StreamDescriptor {
pub fn builder() -> builder::StreamDescriptor {
Default::default()
}
}
///The mechanism in use. Never `chunkedTrustTask`, which has its own descriptor shape; a descriptor naming it with a transport address is malformed.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The mechanism in use. Never `chunkedTrustTask`, which has its own descriptor shape; a descriptor naming it with a transport address is malformed.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct StreamDescriptorAlgorithm(::std::string::String);
impl ::std::ops::Deref for StreamDescriptorAlgorithm {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<StreamDescriptorAlgorithm> for ::std::string::String {
fn from(value: StreamDescriptorAlgorithm) -> Self {
value.0
}
}
impl ::std::str::FromStr for StreamDescriptorAlgorithm {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for StreamDescriptorAlgorithm {
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 StreamDescriptorAlgorithm {
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 StreamDescriptorAlgorithm {
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 StreamDescriptorAlgorithm {
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())
})
}
}
///Bearer credential for transportUrl, presented in the X-Backup-Token header. Minted per bundle and never reused. A recipient should store only a hash of it, and should accept an export token once.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Bearer credential for transportUrl, presented in the X-Backup-Token header. Minted per bundle and never reused. A recipient should store only a hash of it, and should accept an export token once.",
/// "type": "string",
/// "maxLength": 1024,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct StreamDescriptorTransportToken(::std::string::String);
impl ::std::ops::Deref for StreamDescriptorTransportToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<StreamDescriptorTransportToken> for ::std::string::String {
fn from(value: StreamDescriptorTransportToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for StreamDescriptorTransportToken {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for StreamDescriptorTransportToken {
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 StreamDescriptorTransportToken {
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 StreamDescriptorTransportToken {
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 StreamDescriptorTransportToken {
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 ChunkManifest {
chunk_count: ::std::result::Result<super::ChunkCount, ::std::string::String>,
chunk_digests:
::std::result::Result<::std::vec::Vec<super::DigestMultibase>, ::std::string::String>,
chunk_size: ::std::result::Result<super::ChunkSize, ::std::string::String>,
}
impl ::std::default::Default for ChunkManifest {
fn default() -> Self {
Self {
chunk_count: Err("no value supplied for chunk_count".to_string()),
chunk_digests: Err("no value supplied for chunk_digests".to_string()),
chunk_size: Err("no value supplied for chunk_size".to_string()),
}
}
}
impl ChunkManifest {
pub fn chunk_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ChunkCount>,
T::Error: ::std::fmt::Display,
{
self.chunk_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for chunk_count: {e}"));
self
}
pub fn chunk_digests<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::DigestMultibase>>,
T::Error: ::std::fmt::Display,
{
self.chunk_digests = value
.try_into()
.map_err(|e| format!("error converting supplied value for chunk_digests: {e}"));
self
}
pub fn chunk_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ChunkSize>,
T::Error: ::std::fmt::Display,
{
self.chunk_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for chunk_size: {e}"));
self
}
}
impl ::std::convert::TryFrom<ChunkManifest> for super::ChunkManifest {
type Error = super::error::ConversionError;
fn try_from(
value: ChunkManifest,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
chunk_count: value.chunk_count?,
chunk_digests: value.chunk_digests?,
chunk_size: value.chunk_size?,
})
}
}
impl ::std::convert::From<super::ChunkManifest> for ChunkManifest {
fn from(value: super::ChunkManifest) -> Self {
Self {
chunk_count: Ok(value.chunk_count),
chunk_digests: Ok(value.chunk_digests),
chunk_size: Ok(value.chunk_size),
}
}
}
#[derive(Clone, Debug)]
pub struct ChunkedDescriptor {
algorithm: ::std::result::Result<super::ChunkedDescriptorAlgorithm, ::std::string::String>,
bundle_id: ::std::result::Result<super::BundleId, ::std::string::String>,
chunks: ::std::result::Result<super::ChunkManifest, ::std::string::String>,
expected_sha256: ::std::result::Result<super::ExpectedSha256, ::std::string::String>,
expected_size_bytes: ::std::result::Result<super::ExpectedSizeBytes, ::std::string::String>,
expires_at: ::std::result::Result<super::ExpiresAt, ::std::string::String>,
}
impl ::std::default::Default for ChunkedDescriptor {
fn default() -> Self {
Self {
algorithm: Err("no value supplied for algorithm".to_string()),
bundle_id: Err("no value supplied for bundle_id".to_string()),
chunks: Err("no value supplied for chunks".to_string()),
expected_sha256: Err("no value supplied for expected_sha256".to_string()),
expected_size_bytes: Err("no value supplied for expected_size_bytes".to_string()),
expires_at: Err("no value supplied for expires_at".to_string()),
}
}
}
impl ChunkedDescriptor {
pub fn algorithm<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ChunkedDescriptorAlgorithm>,
T::Error: ::std::fmt::Display,
{
self.algorithm = value
.try_into()
.map_err(|e| format!("error converting supplied value for algorithm: {e}"));
self
}
pub fn bundle_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BundleId>,
T::Error: ::std::fmt::Display,
{
self.bundle_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for bundle_id: {e}"));
self
}
pub fn chunks<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ChunkManifest>,
T::Error: ::std::fmt::Display,
{
self.chunks = value
.try_into()
.map_err(|e| format!("error converting supplied value for chunks: {e}"));
self
}
pub fn expected_sha256<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ExpectedSha256>,
T::Error: ::std::fmt::Display,
{
self.expected_sha256 = value
.try_into()
.map_err(|e| format!("error converting supplied value for expected_sha256: {e}"));
self
}
pub fn expected_size_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ExpectedSizeBytes>,
T::Error: ::std::fmt::Display,
{
self.expected_size_bytes = value.try_into().map_err(|e| {
format!("error converting supplied value for expected_size_bytes: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ExpiresAt>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
}
impl ::std::convert::TryFrom<ChunkedDescriptor> for super::ChunkedDescriptor {
type Error = super::error::ConversionError;
fn try_from(
value: ChunkedDescriptor,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
algorithm: value.algorithm?,
bundle_id: value.bundle_id?,
chunks: value.chunks?,
expected_sha256: value.expected_sha256?,
expected_size_bytes: value.expected_size_bytes?,
expires_at: value.expires_at?,
})
}
}
impl ::std::convert::From<super::ChunkedDescriptor> for ChunkedDescriptor {
fn from(value: super::ChunkedDescriptor) -> Self {
Self {
algorithm: Ok(value.algorithm),
bundle_id: Ok(value.bundle_id),
chunks: Ok(value.chunks),
expected_sha256: Ok(value.expected_sha256),
expected_size_bytes: Ok(value.expected_size_bytes),
expires_at: Ok(value.expires_at),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
algorithm: ::std::result::Result<
::std::option::Option<super::PayloadAlgorithm>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
include_audit: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
max_chunk_size:
::std::result::Result<::std::option::Option<super::ChunkSize>, ::std::string::String>,
password: ::std::result::Result<super::PayloadPassword, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
algorithm: Ok(Default::default()),
ext: Ok(Default::default()),
include_audit: Ok(Default::default()),
max_chunk_size: Ok(Default::default()),
password: Err("no value supplied for password".to_string()),
}
}
}
impl Payload {
pub fn algorithm<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadAlgorithm>>,
T::Error: ::std::fmt::Display,
{
self.algorithm = value
.try_into()
.map_err(|e| format!("error converting supplied value for algorithm: {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 include_audit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.include_audit = value
.try_into()
.map_err(|e| format!("error converting supplied value for include_audit: {e}"));
self
}
pub fn max_chunk_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ChunkSize>>,
T::Error: ::std::fmt::Display,
{
self.max_chunk_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for max_chunk_size: {e}"));
self
}
pub fn password<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadPassword>,
T::Error: ::std::fmt::Display,
{
self.password = value
.try_into()
.map_err(|e| format!("error converting supplied value for password: {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 {
algorithm: value.algorithm?,
ext: value.ext?,
include_audit: value.include_audit?,
max_chunk_size: value.max_chunk_size?,
password: value.password?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
algorithm: Ok(value.algorithm),
ext: Ok(value.ext),
include_audit: Ok(value.include_audit),
max_chunk_size: Ok(value.max_chunk_size),
password: Ok(value.password),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
completion_hint: ::std::result::Result<
::std::option::Option<super::ResponseCompletionHint>,
::std::string::String,
>,
descriptor: ::std::result::Result<super::BundleDescriptor, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
completion_hint: Ok(Default::default()),
descriptor: Err("no value supplied for descriptor".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Response {
pub fn completion_hint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCompletionHint>>,
T::Error: ::std::fmt::Display,
{
self.completion_hint = value
.try_into()
.map_err(|e| format!("error converting supplied value for completion_hint: {e}"));
self
}
pub fn descriptor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BundleDescriptor>,
T::Error: ::std::fmt::Display,
{
self.descriptor = value
.try_into()
.map_err(|e| format!("error converting supplied value for descriptor: {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
}
}
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 {
completion_hint: value.completion_hint?,
descriptor: value.descriptor?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
completion_hint: Ok(value.completion_hint),
descriptor: Ok(value.descriptor),
ext: Ok(value.ext),
}
}
}
#[derive(Clone, Debug)]
pub struct StreamDescriptor {
algorithm: ::std::result::Result<super::StreamDescriptorAlgorithm, ::std::string::String>,
bundle_id: ::std::result::Result<super::BundleId, ::std::string::String>,
expected_sha256: ::std::result::Result<super::ExpectedSha256, ::std::string::String>,
expected_size_bytes: ::std::result::Result<super::ExpectedSizeBytes, ::std::string::String>,
expires_at: ::std::result::Result<super::ExpiresAt, ::std::string::String>,
transport_token:
::std::result::Result<super::StreamDescriptorTransportToken, ::std::string::String>,
transport_url: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for StreamDescriptor {
fn default() -> Self {
Self {
algorithm: Err("no value supplied for algorithm".to_string()),
bundle_id: Err("no value supplied for bundle_id".to_string()),
expected_sha256: Err("no value supplied for expected_sha256".to_string()),
expected_size_bytes: Err("no value supplied for expected_size_bytes".to_string()),
expires_at: Err("no value supplied for expires_at".to_string()),
transport_token: Err("no value supplied for transport_token".to_string()),
transport_url: Err("no value supplied for transport_url".to_string()),
}
}
}
impl StreamDescriptor {
pub fn algorithm<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::StreamDescriptorAlgorithm>,
T::Error: ::std::fmt::Display,
{
self.algorithm = value
.try_into()
.map_err(|e| format!("error converting supplied value for algorithm: {e}"));
self
}
pub fn bundle_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BundleId>,
T::Error: ::std::fmt::Display,
{
self.bundle_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for bundle_id: {e}"));
self
}
pub fn expected_sha256<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ExpectedSha256>,
T::Error: ::std::fmt::Display,
{
self.expected_sha256 = value
.try_into()
.map_err(|e| format!("error converting supplied value for expected_sha256: {e}"));
self
}
pub fn expected_size_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ExpectedSizeBytes>,
T::Error: ::std::fmt::Display,
{
self.expected_size_bytes = value.try_into().map_err(|e| {
format!("error converting supplied value for expected_size_bytes: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ExpiresAt>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
pub fn transport_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::StreamDescriptorTransportToken>,
T::Error: ::std::fmt::Display,
{
self.transport_token = value
.try_into()
.map_err(|e| format!("error converting supplied value for transport_token: {e}"));
self
}
pub fn transport_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.transport_url = value
.try_into()
.map_err(|e| format!("error converting supplied value for transport_url: {e}"));
self
}
}
impl ::std::convert::TryFrom<StreamDescriptor> for super::StreamDescriptor {
type Error = super::error::ConversionError;
fn try_from(
value: StreamDescriptor,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
algorithm: value.algorithm?,
bundle_id: value.bundle_id?,
expected_sha256: value.expected_sha256?,
expected_size_bytes: value.expected_size_bytes?,
expires_at: value.expires_at?,
transport_token: value.transport_token?,
transport_url: value.transport_url?,
})
}
}
impl ::std::convert::From<super::StreamDescriptor> for StreamDescriptor {
fn from(value: super::StreamDescriptor) -> Self {
Self {
algorithm: Ok(value.algorithm),
bundle_id: Ok(value.bundle_id),
expected_sha256: Ok(value.expected_sha256),
expected_size_bytes: Ok(value.expected_size_bytes),
expires_at: Ok(value.expires_at),
transport_token: Ok(value.transport_token),
transport_url: Ok(value.transport_url),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/backup/initiate-export/1.1";
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 \"BundleDescriptor\": {\n \"description\": \"The control-plane account of a bundle transfer: which algorithm, on what terms, until when. Exactly one of the two shapes — they are mutually exclusive, since StreamDescriptor requires `transportUrl` and `transportToken` and forbids `chunks`, and ChunkedDescriptor requires `chunks` and forbids both.\",\n \"oneOf\": [\n {\n \"$ref\": \"#/$defs/StreamDescriptor\"\n },\n {\n \"$ref\": \"#/$defs/ChunkedDescriptor\"\n }\n ],\n \"title\": \"BundleDescriptor\"\n },\n \"BundleId\": {\n \"description\": \"Handle for a bundle across its whole lifecycle. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence. Opaque: a producer quotes what it was given and must not derive, guess or enumerate one.\",\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\",\n \"title\": \"BundleId\",\n \"type\": \"string\"\n },\n \"ChunkCount\": {\n \"description\": \"Number of chunks in the bundle, equal to ceil(expectedSizeBytes / chunkSize). Bounded at 4096 so that the manifest itself — one digest per chunk — fits in the single document that carries it under the same message-size reasoning as a chunk.\",\n \"maximum\": 4096,\n \"minimum\": 1,\n \"title\": \"ChunkCount\",\n \"type\": \"integer\"\n },\n \"ChunkManifest\": {\n \"additionalProperties\": false,\n \"description\": \"The terms of a `chunkedTrustTask` transfer, committed before any chunk moves. On export the recipient states them in the descriptor; on import the producer pre-commits them in the request and the recipient echoes them. Either way the manifest arrives in a document whose proof is REQUIRED, so the per-chunk digests are authenticated by the party that computed them and each chunk can be verified — and a single bad chunk re-fetched or refused — on arrival rather than only after reassembly.\\n\\nConsistency rules JSON Schema cannot state: `chunkCount` MUST equal ceil(expectedSizeBytes / chunkSize) for the bundle the manifest describes, and `chunkDigests` MUST have exactly `chunkCount` items. A party receiving a manifest violating either MUST refuse it.\",\n \"properties\": {\n \"chunkCount\": {\n \"$ref\": \"#/$defs/ChunkCount\"\n },\n \"chunkDigests\": {\n \"description\": \"Digest of each chunk's raw bytes (not of its base64url encoding), in index order. Compared as decoded multihash bytes, never as encoded strings. sha2-256 is RECOMMENDED and MUST be implemented by every party; a party that does not implement the hash a digest names MUST treat the manifest as unverifiable rather than skip the check.\",\n \"items\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"maxItems\": 4096,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"chunkSize\": {\n \"$ref\": \"#/$defs/ChunkSize\"\n }\n },\n \"required\": [\n \"chunkSize\",\n \"chunkCount\",\n \"chunkDigests\"\n ],\n \"title\": \"ChunkManifest\",\n \"type\": \"object\"\n },\n \"ChunkSize\": {\n \"description\": \"Size in bytes of every chunk except the last, which carries the remainder and is between 1 and this value inclusive. The ceiling of 262144 (256 KiB) is normative and is derived in `vta/backup/initiate-export/1.1` under Chunked transfer: it is the largest power of two whose `get-chunk` or `put-chunk` document still fits a 1 MiB mediator message after base64url encoding of `data`, DIDComm authcrypt encoding, and two nested forward wrappers. The floor of 16384 keeps a 1 GiB bundle within `ChunkCount`'s ceiling at sizes a constrained transport can still choose.\",\n \"maximum\": 262144,\n \"minimum\": 16384,\n \"title\": \"ChunkSize\",\n \"type\": \"integer\"\n },\n \"ChunkedDescriptor\": {\n \"additionalProperties\": false,\n \"description\": \"A descriptor for the `chunkedTrustTask` algorithm. Carries no address and no bearer token: every chunk moves in a Trust Task document whose sender the transport authenticates, so possession of a token would add nothing and would be one more secret to leak.\",\n \"properties\": {\n \"algorithm\": {\n \"description\": \"Discriminates this shape from StreamDescriptor.\",\n \"enum\": [\n \"chunkedTrustTask\"\n ],\n \"type\": \"string\"\n },\n \"bundleId\": {\n \"$ref\": \"#/$defs/BundleId\"\n },\n \"chunks\": {\n \"$ref\": \"#/$defs/ChunkManifest\"\n },\n \"expectedSha256\": {\n \"$ref\": \"#/$defs/ExpectedSha256\"\n },\n \"expectedSizeBytes\": {\n \"$ref\": \"#/$defs/ExpectedSizeBytes\"\n },\n \"expiresAt\": {\n \"$ref\": \"#/$defs/ExpiresAt\"\n }\n },\n \"required\": [\n \"bundleId\",\n \"algorithm\",\n \"chunks\",\n \"expectedSha256\",\n \"expectedSizeBytes\",\n \"expiresAt\"\n ],\n \"title\": \"ChunkedDescriptor\",\n \"type\": \"object\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"ExpectedSha256\": {\n \"description\": \"Lowercase hex SHA-256 of the whole bundle's bytes. Kept in the hex form the 1.0 descriptor published rather than moved to DigestMultibase, because it is an unchanged member of an existing descriptor and re-encoding it would break every stream producer for no gain in what it checks. For a chunked transfer it is the check over the reassembled bundle, applied after every chunk has verified individually, so that a correct set of chunks assembled in the wrong order is still caught.\",\n \"pattern\": \"^[0-9a-f]{64}$\",\n \"title\": \"ExpectedSha256\",\n \"type\": \"string\"\n },\n \"ExpectedSizeBytes\": {\n \"description\": \"Total byte count of the bundle. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.\",\n \"minimum\": 1,\n \"title\": \"ExpectedSizeBytes\",\n \"type\": \"integer\"\n },\n \"ExpiresAt\": {\n \"description\": \"After which the bundle is collected: staged bytes discarded, tokens and chunk requests refused. Short by design. For a chunked transfer a recipient may move it later as chunks are exchanged, never past its own ceiling — each chunk response reports the current value.\",\n \"format\": \"date-time\",\n \"title\": \"ExpiresAt\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"completionHint\": {\n \"description\": \"Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.\",\n \"maxLength\": 1024,\n \"type\": \"string\"\n },\n \"descriptor\": {\n \"$ref\": \"#/$defs/BundleDescriptor\",\n \"description\": \"Where the bytes are, or how they are divided, what they should be, and until when.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n }\n },\n \"required\": [\n \"descriptor\"\n ],\n \"title\": \"VTA Backup Initiate Export — response payload\",\n \"type\": \"object\"\n },\n \"StreamDescriptor\": {\n \"additionalProperties\": false,\n \"description\": \"A descriptor for a transfer that happens outside Trust Task documents, at an address the recipient publishes — the `stream` algorithm, and any other algorithm a recipient offers that is shaped as an address plus a bearer credential. Identical in members to the `vta/backup/*/1.0` descriptor.\",\n \"properties\": {\n \"algorithm\": {\n \"description\": \"The mechanism in use. Never `chunkedTrustTask`, which has its own descriptor shape; a descriptor naming it with a transport address is malformed.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"bundleId\": {\n \"$ref\": \"#/$defs/BundleId\"\n },\n \"expectedSha256\": {\n \"$ref\": \"#/$defs/ExpectedSha256\"\n },\n \"expectedSizeBytes\": {\n \"$ref\": \"#/$defs/ExpectedSizeBytes\"\n },\n \"expiresAt\": {\n \"$ref\": \"#/$defs/ExpiresAt\"\n },\n \"transportToken\": {\n \"description\": \"Bearer credential for transportUrl, presented in the X-Backup-Token header. Minted per bundle and never reused. A recipient should store only a hash of it, and should accept an export token once.\",\n \"maxLength\": 1024,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"transportUrl\": {\n \"description\": \"Where to fetch (export) or write (import) the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unusable one. An import address is write-only: staged bytes are never served back from it.\",\n \"format\": \"uri\",\n \"maxLength\": 2048,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"bundleId\",\n \"algorithm\",\n \"transportUrl\",\n \"transportToken\",\n \"expectedSha256\",\n \"expectedSizeBytes\",\n \"expiresAt\"\n ],\n \"title\": \"StreamDescriptor\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vta/backup/initiate-export/1.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Asks the recipient to serialize its entire state into a password-encrypted bundle and return the descriptor that fetches it — by an HTTPS address (`stream`) or chunk by chunk over Trust Task documents (`chunkedTrustTask`). The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\n \"properties\": {\n \"algorithm\": {\n \"description\": \"Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (one HTTPS transfer; what an absent member means) and `chunkedTrustTask` (a sequence of get-chunk tasks over the transport already carrying this one). Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"includeAudit\": {\n \"description\": \"Serialize the audit trail alongside the operational state. Absent means false — stated in prose rather than as a schema `default`, because a materialised default turns an omitted member into an asserted one in generated bindings, which is a different document.\",\n \"type\": \"boolean\"\n },\n \"maxChunkSize\": {\n \"$ref\": \"#/$defs/ChunkSize\",\n \"description\": \"For `chunkedTrustTask` only: the largest chunk the producer can receive, for a producer whose transport is tighter than the one the normative ceiling assumes. The recipient chooses a chunkSize no larger than this. Absent means the normative ceiling. Meaningless for any other algorithm, and a recipient ignores it there.\"\n },\n \"password\": {\n \"$comment\": \"No `format: password` — the annotation is advisory in 2020-12 and says less than writeOnly does. No example value anywhere in this directory: a specimen password is the one thing implementers copy.\",\n \"description\": \"Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.\",\n \"maxLength\": 1024,\n \"minLength\": 15,\n \"type\": \"string\",\n \"writeOnly\": true\n }\n },\n \"required\": [\n \"password\"\n ],\n \"title\": \"VTA Backup — Initiate Export — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/backup/initiate-export/1.1#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 \"BundleDescriptor\": {\n \"description\": \"The control-plane account of a bundle transfer: which algorithm, on what terms, until when. Exactly one of the two shapes — they are mutually exclusive, since StreamDescriptor requires `transportUrl` and `transportToken` and forbids `chunks`, and ChunkedDescriptor requires `chunks` and forbids both.\",\n \"oneOf\": [\n {\n \"$ref\": \"#/$defs/StreamDescriptor\"\n },\n {\n \"$ref\": \"#/$defs/ChunkedDescriptor\"\n }\n ],\n \"title\": \"BundleDescriptor\"\n },\n \"BundleId\": {\n \"description\": \"Handle for a bundle across its whole lifecycle. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence. Opaque: a producer quotes what it was given and must not derive, guess or enumerate one.\",\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\",\n \"title\": \"BundleId\",\n \"type\": \"string\"\n },\n \"ChunkCount\": {\n \"description\": \"Number of chunks in the bundle, equal to ceil(expectedSizeBytes / chunkSize). Bounded at 4096 so that the manifest itself — one digest per chunk — fits in the single document that carries it under the same message-size reasoning as a chunk.\",\n \"maximum\": 4096,\n \"minimum\": 1,\n \"title\": \"ChunkCount\",\n \"type\": \"integer\"\n },\n \"ChunkManifest\": {\n \"additionalProperties\": false,\n \"description\": \"The terms of a `chunkedTrustTask` transfer, committed before any chunk moves. On export the recipient states them in the descriptor; on import the producer pre-commits them in the request and the recipient echoes them. Either way the manifest arrives in a document whose proof is REQUIRED, so the per-chunk digests are authenticated by the party that computed them and each chunk can be verified — and a single bad chunk re-fetched or refused — on arrival rather than only after reassembly.\\n\\nConsistency rules JSON Schema cannot state: `chunkCount` MUST equal ceil(expectedSizeBytes / chunkSize) for the bundle the manifest describes, and `chunkDigests` MUST have exactly `chunkCount` items. A party receiving a manifest violating either MUST refuse it.\",\n \"properties\": {\n \"chunkCount\": {\n \"$ref\": \"#/$defs/ChunkCount\"\n },\n \"chunkDigests\": {\n \"description\": \"Digest of each chunk's raw bytes (not of its base64url encoding), in index order. Compared as decoded multihash bytes, never as encoded strings. sha2-256 is RECOMMENDED and MUST be implemented by every party; a party that does not implement the hash a digest names MUST treat the manifest as unverifiable rather than skip the check.\",\n \"items\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"maxItems\": 4096,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"chunkSize\": {\n \"$ref\": \"#/$defs/ChunkSize\"\n }\n },\n \"required\": [\n \"chunkSize\",\n \"chunkCount\",\n \"chunkDigests\"\n ],\n \"title\": \"ChunkManifest\",\n \"type\": \"object\"\n },\n \"ChunkSize\": {\n \"description\": \"Size in bytes of every chunk except the last, which carries the remainder and is between 1 and this value inclusive. The ceiling of 262144 (256 KiB) is normative and is derived in `vta/backup/initiate-export/1.1` under Chunked transfer: it is the largest power of two whose `get-chunk` or `put-chunk` document still fits a 1 MiB mediator message after base64url encoding of `data`, DIDComm authcrypt encoding, and two nested forward wrappers. The floor of 16384 keeps a 1 GiB bundle within `ChunkCount`'s ceiling at sizes a constrained transport can still choose.\",\n \"maximum\": 262144,\n \"minimum\": 16384,\n \"title\": \"ChunkSize\",\n \"type\": \"integer\"\n },\n \"ChunkedDescriptor\": {\n \"additionalProperties\": false,\n \"description\": \"A descriptor for the `chunkedTrustTask` algorithm. Carries no address and no bearer token: every chunk moves in a Trust Task document whose sender the transport authenticates, so possession of a token would add nothing and would be one more secret to leak.\",\n \"properties\": {\n \"algorithm\": {\n \"description\": \"Discriminates this shape from StreamDescriptor.\",\n \"enum\": [\n \"chunkedTrustTask\"\n ],\n \"type\": \"string\"\n },\n \"bundleId\": {\n \"$ref\": \"#/$defs/BundleId\"\n },\n \"chunks\": {\n \"$ref\": \"#/$defs/ChunkManifest\"\n },\n \"expectedSha256\": {\n \"$ref\": \"#/$defs/ExpectedSha256\"\n },\n \"expectedSizeBytes\": {\n \"$ref\": \"#/$defs/ExpectedSizeBytes\"\n },\n \"expiresAt\": {\n \"$ref\": \"#/$defs/ExpiresAt\"\n }\n },\n \"required\": [\n \"bundleId\",\n \"algorithm\",\n \"chunks\",\n \"expectedSha256\",\n \"expectedSizeBytes\",\n \"expiresAt\"\n ],\n \"title\": \"ChunkedDescriptor\",\n \"type\": \"object\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"ExpectedSha256\": {\n \"description\": \"Lowercase hex SHA-256 of the whole bundle's bytes. Kept in the hex form the 1.0 descriptor published rather than moved to DigestMultibase, because it is an unchanged member of an existing descriptor and re-encoding it would break every stream producer for no gain in what it checks. For a chunked transfer it is the check over the reassembled bundle, applied after every chunk has verified individually, so that a correct set of chunks assembled in the wrong order is still caught.\",\n \"pattern\": \"^[0-9a-f]{64}$\",\n \"title\": \"ExpectedSha256\",\n \"type\": \"string\"\n },\n \"ExpectedSizeBytes\": {\n \"description\": \"Total byte count of the bundle. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.\",\n \"minimum\": 1,\n \"title\": \"ExpectedSizeBytes\",\n \"type\": \"integer\"\n },\n \"ExpiresAt\": {\n \"description\": \"After which the bundle is collected: staged bytes discarded, tokens and chunk requests refused. Short by design. For a chunked transfer a recipient may move it later as chunks are exchanged, never past its own ceiling — each chunk response reports the current value.\",\n \"format\": \"date-time\",\n \"title\": \"ExpiresAt\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"completionHint\": {\n \"description\": \"Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.\",\n \"maxLength\": 1024,\n \"type\": \"string\"\n },\n \"descriptor\": {\n \"$ref\": \"#/$defs/BundleDescriptor\",\n \"description\": \"Where the bytes are, or how they are divided, what they should be, and until when.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n }\n },\n \"required\": [\n \"descriptor\"\n ],\n \"title\": \"VTA Backup Initiate Export — response payload\",\n \"type\": \"object\"\n },\n \"StreamDescriptor\": {\n \"additionalProperties\": false,\n \"description\": \"A descriptor for a transfer that happens outside Trust Task documents, at an address the recipient publishes — the `stream` algorithm, and any other algorithm a recipient offers that is shaped as an address plus a bearer credential. Identical in members to the `vta/backup/*/1.0` descriptor.\",\n \"properties\": {\n \"algorithm\": {\n \"description\": \"The mechanism in use. Never `chunkedTrustTask`, which has its own descriptor shape; a descriptor naming it with a transport address is malformed.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"bundleId\": {\n \"$ref\": \"#/$defs/BundleId\"\n },\n \"expectedSha256\": {\n \"$ref\": \"#/$defs/ExpectedSha256\"\n },\n \"expectedSizeBytes\": {\n \"$ref\": \"#/$defs/ExpectedSizeBytes\"\n },\n \"expiresAt\": {\n \"$ref\": \"#/$defs/ExpiresAt\"\n },\n \"transportToken\": {\n \"description\": \"Bearer credential for transportUrl, presented in the X-Backup-Token header. Minted per bundle and never reused. A recipient should store only a hash of it, and should accept an export token once.\",\n \"maxLength\": 1024,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"transportUrl\": {\n \"description\": \"Where to fetch (export) or write (import) the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unusable one. An import address is write-only: staged bytes are never served back from it.\",\n \"format\": \"uri\",\n \"maxLength\": 2048,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"bundleId\",\n \"algorithm\",\n \"transportUrl\",\n \"transportToken\",\n \"expectedSha256\",\n \"expectedSizeBytes\",\n \"expiresAt\"\n ],\n \"title\": \"StreamDescriptor\",\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;
}
/// 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::TRANSPORT_UNAVAILABLE,
error_codes::WEAK_PASSWORD,
error_codes::UNSUPPORTED_ALGORITHM,
error_codes::TOO_MANY_OPEN_BUNDLES,
error_codes::BUNDLE_TOO_LARGE,
];
/// 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 {
/// `vta/backup/initiate-export:transportUnavailable`
///
/// The recipient cannot move the bytes by the requested algorithm — for `stream`, it has no address at which it can publish them. Not a fault in the request — see Transport preconditions.
///
/// Declared `retryable: false`.
pub const TRANSPORT_UNAVAILABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:transportUnavailable",
retryable: false,
};
/// `vta/backup/initiate-export:weakPassword`
///
/// The password is shorter than the recipient's floor. Refused before any state is serialized.
///
/// Declared `retryable: false`.
pub const WEAK_PASSWORD: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:weakPassword",
retryable: false,
};
/// `vta/backup/initiate-export:unsupportedAlgorithm`
///
/// The recipient does not implement the requested transport algorithm. The message names what it does implement.
///
/// Declared `retryable: false`.
pub const UNSUPPORTED_ALGORITHM: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:unsupportedAlgorithm",
retryable: false,
};
/// `vta/backup/initiate-export:tooManyOpenBundles`
///
/// This operator already holds the maximum number of live bundles. Abort one or wait for expiry.
///
/// Declared `retryable: true`.
pub const TOO_MANY_OPEN_BUNDLES: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:tooManyOpenBundles",
retryable: true,
};
/// `vta/backup/initiate-export:bundleTooLarge`
///
/// The serialized bundle cannot be divided into at most 4096 chunks no larger than the chunk size the recipient may use for this producer. Only raised for `chunkedTrustTask`; the staged bytes are discarded before the error is returned.
///
/// Declared `retryable: false`.
pub const BUNDLE_TOO_LARGE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:bundleTooLarge",
retryable: false,
};
}
#[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\": \"urn:uuid:00000000-0000-4000-8000-000000000001\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-export/1.1#request\",\n \"issuer\": \"did:example:operator\",\n \"recipient\": \"did:example:agent\",\n \"issuedAt\": \"2026-01-01T00:00:00Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000ff\",\n \"payload\": {\n \"password\": \"correct horse battery staple\",\n \"includeAudit\": true\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 request_example_2() {
const JSON: &str = "{\n \"id\": \"urn:uuid:00000000-0000-4000-8000-000000000011\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-export/1.1#request\",\n \"issuer\": \"did:example:operator\",\n \"recipient\": \"did:example:agent\",\n \"issuedAt\": \"2026-01-01T02:00:00Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000fd\",\n \"payload\": {\n \"password\": \"correct horse battery staple\",\n \"includeAudit\": false,\n \"algorithm\": \"chunkedTrustTask\"\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\": \"urn:uuid:00000000-0000-4000-8000-000000000002\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-export/1.1#response\",\n \"issuer\": \"did:example:agent\",\n \"recipient\": \"did:example:operator\",\n \"issuedAt\": \"2026-01-01T00:00:01Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000ff\",\n \"payload\": {\n \"descriptor\": {\n \"bundleId\": \"3f2504e0-4f89-41d3-9a0c-0305e82c3301\",\n \"algorithm\": \"stream\",\n \"transportUrl\": \"https://agent.example/backup/blob/3f2504e0-4f89-41d3-9a0c-0305e82c3301\",\n \"transportToken\": \"dGhpcy1pcy1hLW9uZS1zaG90LWJlYXJlci10b2tlbg\",\n \"expectedSha256\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n \"expectedSizeBytes\": 1048576,\n \"expiresAt\": \"2026-01-01T00:05:01Z\"\n },\n \"completionHint\": \"GET the transportUrl with header X-Backup-Token, then send complete-export.\"\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");
}
#[test]
fn response_example_2() {
const JSON: &str = "{\n \"id\": \"urn:uuid:00000000-0000-4000-8000-000000000012\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-export/1.1#response\",\n \"issuer\": \"did:example:agent\",\n \"recipient\": \"did:example:operator\",\n \"issuedAt\": \"2026-01-01T02:00:02Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000fd\",\n \"payload\": {\n \"descriptor\": {\n \"bundleId\": \"5b1f4a2e-7c3d-4e8f-9a6b-2d0c1e3f4a5b\",\n \"algorithm\": \"chunkedTrustTask\",\n \"chunks\": {\n \"chunkSize\": 262144,\n \"chunkCount\": 3,\n \"chunkDigests\": [\n \"zQmehatQCtXyeV6kFkRVXjhDifqT3qARJ24248K2GJp7iWx\",\n \"zQmaFd25Uf6hJJ8xHX349DLzp4sryKmTGuyaSZWVtwsK5rM\",\n \"zQmTcWLvAPe4Txz32vVqZe5jgX4nBPiaBsTTCp4bLXDMzTT\"\n ]\n },\n \"expectedSha256\": \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"expectedSizeBytes\": 524300,\n \"expiresAt\": \"2026-01-01T02:10:02Z\"\n },\n \"completionHint\": \"Send get-chunk for indices 0 to 2, verify each, then send complete-export.\"\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");
}
/// Each fixture in `payload.invalid-examples.json` MUST be
/// rejected by at least one of: serde deserialization, or
/// JSON-Schema validation under the `validate` feature. The
/// fixture file documents the producer-side bug class that
/// each payload exemplifies; this generated test pins it.
#[cfg(feature = "validate")]
#[test]
fn rejects_invalid_examples() {
use crate::validate::ValidatedPayload;
let fixtures: &[(&str, &str)] = &[
(
"Missing `password`. There is no unencrypted export and no recipient-chosen default — an absent password must never read as 'encrypt it with something'.",
"{}",
),
(
"Short `password`. minLength is the shape floor; a recipient may require more and refuses with weakPassword. Caught here so the check happens before any state is serialized.",
"{\n \"password\": \"short\"\n}",
),
(
"Unbounded `algorithm` — §7.3 item 19. The value is echoed into the descriptor and into an audit entry; maxLength is what keeps both bounded.",
"{\n \"algorithm\": \"sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\",\n \"password\": \"a sufficiently long secret\"\n}",
),
(
"`includeAudit` as the string \"true\". A producer that means to exclude the trail and sends \"false\" would otherwise be read as truthy by a lenient consumer, widening the bundle silently.",
"{\n \"includeAudit\": \"true\",\n \"password\": \"a sufficiently long secret\"\n}",
),
(
"Bare/unnamespaced ext key — SPEC §4.5.1 requires every immediate child of ext to be reverse-DNS namespaced.",
"{\n \"ext\": {\n \"bare-key\": {\n \"anything\": \"here\"\n }\n },\n \"password\": \"a sufficiently long secret\"\n}",
),
(
"Unknown top-level member — additionalProperties: false catches `bundleId`. The producer asks for an export; it does not name the bundle, because minting the handle is what the recipient is being asked to do.",
"{\n \"bundleId\": \"3f2504e0-4f89-41d3-9a0c-0305e82c3301\",\n \"password\": \"a sufficiently long secret\"\n}",
),
(
"`maxChunkSize` above the 262144-byte ceiling. The ceiling is what keeps a chunk document inside a 1 MiB mediator message; a producer cannot talk a recipient past it, because the message that exceeds it is refused by an intermediary neither party controls.",
"{\n \"algorithm\": \"chunkedTrustTask\",\n \"maxChunkSize\": 524288,\n \"password\": \"a sufficiently long secret\"\n}",
),
(
"`maxChunkSize` below the 16384-byte floor. A chunk size that small cannot reach a useful bundle within the 4096-chunk bound.",
"{\n \"algorithm\": \"chunkedTrustTask\",\n \"maxChunkSize\": 1024,\n \"password\": \"a sufficiently long secret\"\n}",
),
];
for (i, (note, raw)) in fixtures.iter().enumerate() {
let value: serde_json::Value = match serde_json::from_str(raw) {
Ok(v) => v,
Err(_) => continue,
};
let serde_ok = serde_json::from_value::<super::Payload>(value.clone()).is_ok();
let schema_ok = super::Payload::validate_value(&value).is_ok();
assert!(
!(serde_ok && schema_ok),
"invalid-example #{} ({:?}) was accepted by both serde and JSON Schema; \
the fixture's stated failure class is no longer caught:\n{}",
i + 1,
note,
raw
);
}
}
}