//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/backup/initiate-import`. 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 open a slot for an encrypted bundle the producer is about to upload — by an HTTPS address (`stream`) or chunk by chunk over Trust Task documents (`chunkedTrustTask`) — pre-committing the digest and size, and for a chunked upload the chunk manifest, so the transfer is verifiable. 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-import/1.1",
/// "title": "Payload",
/// "description": "Asks the recipient to open a slot for an encrypted bundle the producer is about to upload — by an HTTPS address (`stream`) or chunk by chunk over Trust Task documents (`chunkedTrustTask`) — pre-committing the digest and size, and for a chunked upload the chunk manifest, so the transfer is verifiable. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.",
/// "type": "object",
/// "required": [
/// "expectedSha256",
/// "expectedSizeBytes"
/// ],
/// "properties": {
/// "algorithm": {
/// "description": "Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (what an absent member means) and `chunkedTrustTask`. Deliberately not an enum, so a recipient offering more can be asked for it without a specification revision; one that does not implement the request refuses with unsupportedAlgorithm.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
/// },
/// "chunks": {
/// "description": "The chunk manifest the upload will follow. REQUIRED when `algorithm` is `chunkedTrustTask` and forbidden otherwise — a rule over two members that this schema does not express; a recipient refuses a violation with invalidManifest. Pre-committed for the same reason the whole-bundle digest is: the recipient knows what each chunk must be before it receives any.",
/// "$ref": "#/definitions/ChunkManifest"
/// },
/// "expectedSha256": {
/// "description": "Lowercase hex SHA-256 of the whole bundle about to be uploaded, committed before the upload begins. The recipient refuses bytes that hash differently, which is what bounds the damage from a leaked write token or a substituted chunk. A wire-integrity check only: it says the bytes that arrived are the bytes that were sent, and nothing about whether they are worth applying.",
/// "$ref": "#/definitions/ExpectedSha256"
/// },
/// "expectedSizeBytes": {
/// "description": "Byte count of the upload. Lets the recipient size the slot and refuse a truncated or oversized transfer without hashing it first.",
/// "$ref": "#/definitions/ExpectedSizeBytes"
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "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` (what an absent member means) and `chunkedTrustTask`. Deliberately not an enum, so a recipient offering more can be asked for it without a specification revision; 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>,
///The chunk manifest the upload will follow. REQUIRED when `algorithm` is `chunkedTrustTask` and forbidden otherwise — a rule over two members that this schema does not express; a recipient refuses a violation with invalidManifest. Pre-committed for the same reason the whole-bundle digest is: the recipient knows what each chunk must be before it receives any.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub chunks: ::std::option::Option<ChunkManifest>,
///Lowercase hex SHA-256 of the whole bundle about to be uploaded, committed before the upload begins. The recipient refuses bytes that hash differently, which is what bounds the damage from a leaked write token or a substituted chunk. A wire-integrity check only: it says the bytes that arrived are the bytes that were sent, and nothing about whether they are worth applying.
#[serde(rename = "expectedSha256")]
pub expected_sha256: ExpectedSha256,
///Byte count of the upload. Lets the recipient size the slot and refuse a truncated or oversized transfer without hashing it first.
#[serde(rename = "expectedSizeBytes")]
pub expected_size_bytes: ExpectedSizeBytes,
///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 Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Requested transport mechanism — how the bytes move, not how they are encrypted. This version defines `stream` (what an absent member means) and `chunkedTrustTask`. Deliberately not an enum, so a recipient offering more can be asked for it without a specification revision; 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` (what an absent member means) and `chunkedTrustTask`. Deliberately not an enum, so a recipient offering more can be asked for it without a specification revision; 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())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "descriptor"
/// ],
/// "properties": {
/// "completionHint": {
/// "description": "Operator-facing text describing how to complete the upload. 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 or how to write the bytes, on what terms, 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 upload. 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 or how to write the bytes, on what terms, 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 upload. 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 upload. 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,
>,
chunks: ::std::result::Result<
::std::option::Option<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>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
algorithm: Ok(Default::default()),
chunks: Ok(Default::default()),
expected_sha256: Err("no value supplied for expected_sha256".to_string()),
expected_size_bytes: Err("no value supplied for expected_size_bytes".to_string()),
ext: Ok(Default::default()),
}
}
}
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 chunks<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<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 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<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?,
chunks: value.chunks?,
expected_sha256: value.expected_sha256?,
expected_size_bytes: value.expected_size_bytes?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
algorithm: Ok(value.algorithm),
chunks: Ok(value.chunks),
expected_sha256: Ok(value.expected_sha256),
expected_size_bytes: Ok(value.expected_size_bytes),
ext: Ok(value.ext),
}
}
}
#[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-import/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 upload. 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 or how to write the bytes, on what terms, 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 Import — 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-import/1.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Asks the recipient to open a slot for an encrypted bundle the producer is about to upload — by an HTTPS address (`stream`) or chunk by chunk over Trust Task documents (`chunkedTrustTask`) — pre-committing the digest and size, and for a chunked upload the chunk manifest, so the transfer is verifiable. 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` (what an absent member means) and `chunkedTrustTask`. Deliberately not an enum, so a recipient offering more can be asked for it without a specification revision; one that does not implement the request refuses with unsupportedAlgorithm.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"chunks\": {\n \"$ref\": \"#/$defs/ChunkManifest\",\n \"description\": \"The chunk manifest the upload will follow. REQUIRED when `algorithm` is `chunkedTrustTask` and forbidden otherwise — a rule over two members that this schema does not express; a recipient refuses a violation with invalidManifest. Pre-committed for the same reason the whole-bundle digest is: the recipient knows what each chunk must be before it receives any.\"\n },\n \"expectedSha256\": {\n \"$ref\": \"#/$defs/ExpectedSha256\",\n \"description\": \"Lowercase hex SHA-256 of the whole bundle about to be uploaded, committed before the upload begins. The recipient refuses bytes that hash differently, which is what bounds the damage from a leaked write token or a substituted chunk. A wire-integrity check only: it says the bytes that arrived are the bytes that were sent, and nothing about whether they are worth applying.\"\n },\n \"expectedSizeBytes\": {\n \"$ref\": \"#/$defs/ExpectedSizeBytes\",\n \"description\": \"Byte count of the upload. Lets the recipient size the slot and refuse a truncated or oversized transfer without hashing it first.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n }\n },\n \"required\": [\n \"expectedSha256\",\n \"expectedSizeBytes\"\n ],\n \"title\": \"VTA Backup — Initiate Import — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/backup/initiate-import/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 upload. 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 or how to write the bytes, on what terms, 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 Import — 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::UNSUPPORTED_ALGORITHM,
error_codes::INVALID_DIGEST,
error_codes::INVALID_MANIFEST,
error_codes::CHUNK_SIZE_UNACCEPTABLE,
error_codes::TRANSPORT_UNAVAILABLE,
error_codes::TOO_MANY_OPEN_BUNDLES,
];
/// 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-import: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-import:unsupportedAlgorithm",
retryable: false,
};
/// `vta/backup/initiate-import:invalidDigest`
///
/// `expectedSha256` is not 64 lowercase hex characters, or `expectedSizeBytes` is not a positive count. Refused before a slot is opened.
///
/// Declared `retryable: false`.
pub const INVALID_DIGEST: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-import:invalidDigest",
retryable: false,
};
/// `vta/backup/initiate-import:invalidManifest`
///
/// For `chunkedTrustTask`: `chunks` is absent, or its `chunkCount` does not match `expectedSizeBytes` and `chunkSize`, or `chunkDigests` does not hold one digest per chunk, or a digest names a hash the recipient does not implement. For any other algorithm: `chunks` is present. Refused before a slot is opened.
///
/// Declared `retryable: false`.
pub const INVALID_MANIFEST: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-import:invalidManifest",
retryable: false,
};
/// `vta/backup/initiate-import:chunkSizeUnacceptable`
///
/// The manifest's `chunkSize` is within the normative bound but larger than the recipient accepts over the transport in use. `details.maxChunkSize` names the largest it does accept; the producer re-divides and asks again.
///
/// Declared `retryable: false`.
pub const CHUNK_SIZE_UNACCEPTABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-import:chunkSizeUnacceptable",
retryable: false,
};
/// `vta/backup/initiate-import:transportUnavailable`
///
/// The recipient cannot accept the bytes by the requested algorithm — for `stream`, it has no address at which it can accept 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-import:transportUnavailable",
retryable: false,
};
/// `vta/backup/initiate-import: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-import:tooManyOpenBundles",
retryable: true,
};
}
#[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-000000000007\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-import/1.1#request\",\n \"issuer\": \"did:example:operator\",\n \"recipient\": \"did:example:agent\",\n \"issuedAt\": \"2026-01-01T01:00:00Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000fe\",\n \"payload\": {\n \"expectedSha256\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n \"expectedSizeBytes\": 1048576\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-000000000017\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-import/1.1#request\",\n \"issuer\": \"did:example:operator\",\n \"recipient\": \"did:example:agent\",\n \"issuedAt\": \"2026-01-01T03:00:00Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000fc\",\n \"payload\": {\n \"expectedSha256\": \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"expectedSizeBytes\": 524300,\n \"algorithm\": \"chunkedTrustTask\",\n \"chunks\": {\n \"chunkSize\": 262144,\n \"chunkCount\": 3,\n \"chunkDigests\": [\n \"zQmehatQCtXyeV6kFkRVXjhDifqT3qARJ24248K2GJp7iWx\",\n \"zQmaFd25Uf6hJJ8xHX349DLzp4sryKmTGuyaSZWVtwsK5rM\",\n \"zQmTcWLvAPe4Txz32vVqZe5jgX4nBPiaBsTTCp4bLXDMzTT\"\n ]\n }\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-000000000008\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-import/1.1#response\",\n \"issuer\": \"did:example:agent\",\n \"recipient\": \"did:example:operator\",\n \"issuedAt\": \"2026-01-01T01:00:01Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000fe\",\n \"payload\": {\n \"descriptor\": {\n \"bundleId\": \"9c858901-8a57-4791-81fe-4c455b099bc9\",\n \"algorithm\": \"stream\",\n \"transportUrl\": \"https://agent.example/backup/blob/9c858901-8a57-4791-81fe-4c455b099bc9\",\n \"transportToken\": \"dGhpcy1pcy1hLXdyaXRlLXNsb3QtYmVhcmVyLXRva2Vu\",\n \"expectedSha256\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n \"expectedSizeBytes\": 1048576,\n \"expiresAt\": \"2026-01-01T01:05:01Z\"\n },\n \"completionHint\": \"POST the bundle to the transportUrl with header X-Backup-Token, then send finalize-import.\"\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-000000000018\",\n \"type\": \"https://trusttasks.org/spec/vta/backup/initiate-import/1.1#response\",\n \"issuer\": \"did:example:agent\",\n \"recipient\": \"did:example:operator\",\n \"issuedAt\": \"2026-01-01T03:00:01Z\",\n \"threadId\": \"urn:uuid:00000000-0000-4000-8000-0000000000fc\",\n \"payload\": {\n \"descriptor\": {\n \"bundleId\": \"7e6d5c4b-3a29-4817-a6f5-e4d3c2b1a098\",\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-01T03:10:01Z\"\n },\n \"completionHint\": \"Send put-chunk for indices 0 to 2, then send finalize-import.\"\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 both pre-commitments. A slot opened without a digest accepts whatever arrives, which is exactly the property that makes a leaked write token harmless when they are present.",
"{}",
),
(
"Uppercase hex digest. The pattern fixes one spelling so that a recipient's comparison is a string equality rather than a normalisation it might get wrong.",
"{\n \"expectedSha256\": \"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855\",\n \"expectedSizeBytes\": 1048576\n}",
),
(
"Digest of the wrong length — a SHA-1 in a SHA-256 member. Caught by the pattern before a slot is opened.",
"{\n \"expectedSha256\": \"da39a3ee5e6b4b0d3255bfef95601890afd80709\",\n \"expectedSizeBytes\": 1048576\n}",
),
(
"Zero `expectedSizeBytes`. There is nothing to import, and a slot sized for no bytes would accept an empty upload as a successful transfer.",
"{\n \"expectedSha256\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n \"expectedSizeBytes\": 0\n}",
),
(
"Bare/unnamespaced ext key — SPEC §4.5.1 requires every immediate child of ext to be reverse-DNS namespaced.",
"{\n \"expectedSha256\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n \"expectedSizeBytes\": 1048576,\n \"ext\": {\n \"bare-key\": {\n \"anything\": \"here\"\n }\n }\n}",
),
(
"Unknown top-level member — additionalProperties: false catches `password`. The password belongs to finalize-import; accepting it here would put the decryption secret alongside the slot that holds the ciphertext, which is the one place this family keeps them apart.",
"{\n \"expectedSha256\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n \"expectedSizeBytes\": 1048576,\n \"password\": \"a sufficiently long secret\"\n}",
),
(
"Chunk manifest with `chunkSize` above the 262144-byte ceiling. Every put-chunk that followed would exceed a 1 MiB mediator message and be dropped in transit, so the slot is refused before it opens.",
"{\n \"algorithm\": \"chunkedTrustTask\",\n \"chunks\": {\n \"chunkCount\": 2,\n \"chunkDigests\": [\n \"zQmehatQCtXyeV6kFkRVXjhDifqT3qARJ24248K2GJp7iWx\",\n \"zQmaFd25Uf6hJJ8xHX349DLzp4sryKmTGuyaSZWVtwsK5rM\"\n ],\n \"chunkSize\": 524288\n },\n \"expectedSha256\": \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"expectedSizeBytes\": 524300\n}",
),
(
"Per-chunk digests as bare hex. Chunk digests are DigestMultibase, so the hash algorithm travels with the value; a bare hex string hard-codes one algorithm into the wire contract.",
"{\n \"algorithm\": \"chunkedTrustTask\",\n \"chunks\": {\n \"chunkCount\": 3,\n \"chunkDigests\": [\n \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\"\n ],\n \"chunkSize\": 262144\n },\n \"expectedSha256\": \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"expectedSizeBytes\": 524300\n}",
),
(
"Chunk manifest with no digests. A manifest that commits to nothing lets any bytes be written at any index, which is the substitution the pre-commitment exists to prevent.",
"{\n \"algorithm\": \"chunkedTrustTask\",\n \"chunks\": {\n \"chunkCount\": 3,\n \"chunkDigests\": [],\n \"chunkSize\": 262144\n },\n \"expectedSha256\": \"20111c1d10631a5d6b2e9e06f558cd5c84e841d2bc5758bfda0d3b76bb4927f0\",\n \"expectedSizeBytes\": 524300\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
);
}
}
}