//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/backup/initiate-export`. Version: `1.0`.
#![allow(deprecated)]
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = Some("superseded by vta/backup/initiate-export/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 an out-of-band byte transfer. Shared in shape with initiate-import, where it describes an upload rather than a download.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct BundleDescriptor {
///The mechanism actually used, which is authoritative over what was requested.
pub algorithm: BundleDescriptorAlgorithm,
///Handle for this bundle across its whole lifecycle. Quoted back by complete-export and abort. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence.
#[serde(rename = "bundleId")]
pub bundle_id: BundleDescriptorBundleId,
///Lowercase hex SHA-256 of the byte stream. Independent of the encrypted envelope's own authentication tag, so a truncated or substituted transfer is caught before the password is applied to it.
#[serde(rename = "expectedSha256")]
pub expected_sha256: BundleDescriptorExpectedSha256,
///Total byte count. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.
#[serde(rename = "expectedSizeBytes")]
pub expected_size_bytes: ::std::num::NonZeroU64,
///After which the bytes are collected and the token refused. Short by design: the window is how long a fetchable copy of the agent exists.
#[serde(rename = "expiresAt")]
pub expires_at: ::chrono::DateTime<::chrono::offset::Utc>,
///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 it once — the token plus the URL is the export.
#[serde(rename = "transportToken")]
pub transport_token: BundleDescriptorTransportToken,
///Where to fetch the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unfetchable one.
#[serde(rename = "transportUrl")]
pub transport_url: ::std::string::String,
}
impl BundleDescriptor {
pub fn builder() -> builder::BundleDescriptor {
Default::default()
}
}
///The mechanism actually used, which is authoritative over what was requested.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BundleDescriptorAlgorithm(::std::string::String);
impl ::std::ops::Deref for BundleDescriptorAlgorithm {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<BundleDescriptorAlgorithm> for ::std::string::String {
fn from(value: BundleDescriptorAlgorithm) -> Self {
value.0
}
}
impl ::std::str::FromStr for BundleDescriptorAlgorithm {
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 BundleDescriptorAlgorithm {
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 BundleDescriptorAlgorithm {
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 BundleDescriptorAlgorithm {
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 BundleDescriptorAlgorithm {
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())
})
}
}
///Handle for this bundle across its whole lifecycle. Quoted back by complete-export and abort. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BundleDescriptorBundleId(::std::string::String);
impl ::std::ops::Deref for BundleDescriptorBundleId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<BundleDescriptorBundleId> for ::std::string::String {
fn from(value: BundleDescriptorBundleId) -> Self {
value.0
}
}
impl ::std::str::FromStr for BundleDescriptorBundleId {
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 BundleDescriptorBundleId {
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 BundleDescriptorBundleId {
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 BundleDescriptorBundleId {
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 BundleDescriptorBundleId {
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 byte stream. Independent of the encrypted envelope's own authentication tag, so a truncated or substituted transfer is caught before the password is applied to it.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BundleDescriptorExpectedSha256(::std::string::String);
impl ::std::ops::Deref for BundleDescriptorExpectedSha256 {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<BundleDescriptorExpectedSha256> for ::std::string::String {
fn from(value: BundleDescriptorExpectedSha256) -> Self {
value.0
}
}
impl ::std::str::FromStr for BundleDescriptorExpectedSha256 {
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 BundleDescriptorExpectedSha256 {
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 BundleDescriptorExpectedSha256 {
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 BundleDescriptorExpectedSha256 {
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 BundleDescriptorExpectedSha256 {
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 it once — the token plus the URL is the export.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BundleDescriptorTransportToken(::std::string::String);
impl ::std::ops::Deref for BundleDescriptorTransportToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<BundleDescriptorTransportToken> for ::std::string::String {
fn from(value: BundleDescriptorTransportToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for BundleDescriptorTransportToken {
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 BundleDescriptorTransportToken {
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 BundleDescriptorTransportToken {
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 BundleDescriptorTransportToken {
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 BundleDescriptorTransportToken {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
#[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`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Asks the recipient to serialize its entire state into a password-encrypted bundle and return the descriptor that fetches it. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by vta/backup/initiate-export/1.1")]
pub struct Payload {
///Requested transport mechanism — how the bytes move, not how they are encrypted. `stream` is the only value this version defines and is what an absent member means. Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub algorithm: ::std::option::Option<PayloadAlgorithm>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Serialize the audit trail alongside the operational state. Absent means false — stated in prose rather than as a schema `default`, because a materialised default turns an omitted member into an asserted one in generated bindings, which is a different document.
#[serde(
rename = "includeAudit",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub include_audit: ::std::option::Option<bool>,
///Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.
pub password: PayloadPassword,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Requested transport mechanism — how the bytes move, not how they are encrypted. `stream` is the only value this version defines and is what an absent member means. Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadAlgorithm(::std::string::String);
impl ::std::ops::Deref for PayloadAlgorithm {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadAlgorithm> for ::std::string::String {
fn from(value: PayloadAlgorithm) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadAlgorithm {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadAlgorithm {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadAlgorithm {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadAlgorithm {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadAlgorithm {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadPassword(::std::string::String);
impl ::std::ops::Deref for PayloadPassword {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadPassword> for ::std::string::String {
fn from(value: PayloadPassword) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadPassword {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
if value.chars().count() < 15usize {
return Err("shorter than 15 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadPassword {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadPassword {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadPassword {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadPassword {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Response`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by vta/backup/initiate-export/1.1")]
pub struct Response {
///Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.
#[serde(
rename = "completionHint",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub completion_hint: ::std::option::Option<ResponseCompletionHint>,
///Where the bytes are, what they should be, and until when.
pub descriptor: BundleDescriptor,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.
///
#[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())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct BundleDescriptor {
algorithm: ::std::result::Result<super::BundleDescriptorAlgorithm, ::std::string::String>,
bundle_id: ::std::result::Result<super::BundleDescriptorBundleId, ::std::string::String>,
expected_sha256:
::std::result::Result<super::BundleDescriptorExpectedSha256, ::std::string::String>,
expected_size_bytes: ::std::result::Result<::std::num::NonZeroU64, ::std::string::String>,
expires_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
transport_token:
::std::result::Result<super::BundleDescriptorTransportToken, ::std::string::String>,
transport_url: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for BundleDescriptor {
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 BundleDescriptor {
pub fn algorithm<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BundleDescriptorAlgorithm>,
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::BundleDescriptorBundleId>,
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::BundleDescriptorExpectedSha256>,
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<::std::num::NonZeroU64>,
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<::chrono::DateTime<::chrono::offset::Utc>>,
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::BundleDescriptorTransportToken>,
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<BundleDescriptor> for super::BundleDescriptor {
type Error = super::error::ConversionError;
fn try_from(
value: BundleDescriptor,
) -> ::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::BundleDescriptor> for BundleDescriptor {
fn from(value: super::BundleDescriptor) -> 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),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
algorithm: ::std::result::Result<
::std::option::Option<super::PayloadAlgorithm>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
include_audit: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
password: ::std::result::Result<super::PayloadPassword, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
algorithm: Ok(Default::default()),
ext: Ok(Default::default()),
include_audit: Ok(Default::default()),
password: Err("no value supplied for password".to_string()),
}
}
}
impl Payload {
pub fn algorithm<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadAlgorithm>>,
T::Error: ::std::fmt::Display,
{
self.algorithm = value
.try_into()
.map_err(|e| format!("error converting supplied value for algorithm: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn include_audit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.include_audit = value
.try_into()
.map_err(|e| format!("error converting supplied value for include_audit: {e}"));
self
}
pub fn password<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadPassword>,
T::Error: ::std::fmt::Display,
{
self.password = value
.try_into()
.map_err(|e| format!("error converting supplied value for password: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
algorithm: value.algorithm?,
ext: value.ext?,
include_audit: value.include_audit?,
password: value.password?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
algorithm: Ok(value.algorithm),
ext: Ok(value.ext),
include_audit: Ok(value.include_audit),
password: Ok(value.password),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
completion_hint: ::std::result::Result<
::std::option::Option<super::ResponseCompletionHint>,
::std::string::String,
>,
descriptor: ::std::result::Result<super::BundleDescriptor, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
completion_hint: Ok(Default::default()),
descriptor: Err("no value supplied for descriptor".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Response {
pub fn completion_hint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCompletionHint>>,
T::Error: ::std::fmt::Display,
{
self.completion_hint = value
.try_into()
.map_err(|e| format!("error converting supplied value for completion_hint: {e}"));
self
}
pub fn descriptor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BundleDescriptor>,
T::Error: ::std::fmt::Display,
{
self.descriptor = value
.try_into()
.map_err(|e| format!("error converting supplied value for descriptor: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completion_hint: value.completion_hint?,
descriptor: value.descriptor?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
completion_hint: Ok(value.completion_hint),
descriptor: Ok(value.descriptor),
ext: Ok(value.ext),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/backup/initiate-export/1.0";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"BundleDescriptor\":{\"additionalProperties\":false,\"description\":\"The control-plane account of an out-of-band byte transfer. Shared in shape with initiate-import, where it describes an upload rather than a download.\",\"properties\":{\"algorithm\":{\"description\":\"The mechanism actually used, which is authoritative over what was requested.\",\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"bundleId\":{\"description\":\"Handle for this bundle across its whole lifecycle. Quoted back by complete-export and abort. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence.\",\"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}$\",\"type\":\"string\"},\"expectedSha256\":{\"description\":\"Lowercase hex SHA-256 of the byte stream. Independent of the encrypted envelope's own authentication tag, so a truncated or substituted transfer is caught before the password is applied to it.\",\"pattern\":\"^[0-9a-f]{64}$\",\"type\":\"string\"},\"expectedSizeBytes\":{\"description\":\"Total byte count. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.\",\"minimum\":1,\"type\":\"integer\"},\"expiresAt\":{\"description\":\"After which the bytes are collected and the token refused. Short by design: the window is how long a fetchable copy of the agent exists.\",\"format\":\"date-time\",\"type\":\"string\"},\"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 it once — the token plus the URL is the export.\",\"maxLength\":1024,\"minLength\":1,\"type\":\"string\"},\"transportUrl\":{\"description\":\"Where to fetch the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unfetchable one.\",\"format\":\"uri\",\"maxLength\":2048,\"type\":\"string\"}},\"required\":[\"bundleId\",\"algorithm\",\"transportUrl\",\"transportToken\",\"expectedSha256\",\"expectedSizeBytes\",\"expiresAt\"],\"title\":\"Bundle descriptor\",\"type\":\"object\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"completionHint\":{\"description\":\"Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.\",\"maxLength\":1024,\"type\":\"string\"},\"descriptor\":{\"$ref\":\"#/$defs/BundleDescriptor\",\"description\":\"Where the bytes are, what they should be, and until when.\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"}},\"required\":[\"descriptor\"],\"title\":\"VTA Backup Initiate Export — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vta/backup/initiate-export/1.0\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Asks the recipient to serialize its entire state into a password-encrypted bundle and return the descriptor that fetches it. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\"properties\":{\"algorithm\":{\"description\":\"Requested transport mechanism — how the bytes move, not how they are encrypted. `stream` is the only value this version defines and is what an absent member means. Deliberately not an enum: a recipient offering more must be askable for it without a specification revision, and one that does not implement the request refuses with unsupportedAlgorithm.\",\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"},\"includeAudit\":{\"description\":\"Serialize the audit trail alongside the operational state. Absent means false — stated in prose rather than as a schema `default`, because a materialised default turns an omitted member into an asserted one in generated bindings, which is a different document.\",\"type\":\"boolean\"},\"password\":{\"$comment\":\"No `format: password` — the annotation is advisory in 2020-12 and says less than writeOnly does. No example value anywhere in this directory: a specimen password is the one thing implementers copy.\",\"description\":\"Key-derivation input protecting the bundle. Chosen by the producer and never recoverable from the recipient. `writeOnly` is the machine-readable form of the rule in Data carried: this member goes in and never comes back, so a generated client must not surface it in a response type, and a recipient must never log, echo or persist it. The minLength floor is a shape check only — a recipient may require more, and refuses with weakPassword.\",\"maxLength\":1024,\"minLength\":15,\"type\":\"string\",\"writeOnly\":true}},\"required\":[\"password\"],\"title\":\"VTA Backup — Initiate Export — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/backup/initiate-export/1.0#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"BundleDescriptor\":{\"additionalProperties\":false,\"description\":\"The control-plane account of an out-of-band byte transfer. Shared in shape with initiate-import, where it describes an upload rather than a download.\",\"properties\":{\"algorithm\":{\"description\":\"The mechanism actually used, which is authoritative over what was requested.\",\"maxLength\":64,\"minLength\":1,\"type\":\"string\"},\"bundleId\":{\"description\":\"Handle for this bundle across its whole lifecycle. Quoted back by complete-export and abort. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence.\",\"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}$\",\"type\":\"string\"},\"expectedSha256\":{\"description\":\"Lowercase hex SHA-256 of the byte stream. Independent of the encrypted envelope's own authentication tag, so a truncated or substituted transfer is caught before the password is applied to it.\",\"pattern\":\"^[0-9a-f]{64}$\",\"type\":\"string\"},\"expectedSizeBytes\":{\"description\":\"Total byte count. A zero-length bundle is not a degenerate success — nothing was serialized — so the floor is 1.\",\"minimum\":1,\"type\":\"integer\"},\"expiresAt\":{\"description\":\"After which the bytes are collected and the token refused. Short by design: the window is how long a fetchable copy of the agent exists.\",\"format\":\"date-time\",\"type\":\"string\"},\"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 it once — the token plus the URL is the export.\",\"maxLength\":1024,\"minLength\":1,\"type\":\"string\"},\"transportUrl\":{\"description\":\"Where to fetch the bytes. A recipient with no address at which it is reachable cannot produce this and refuses with transportUnavailable rather than returning an unfetchable one.\",\"format\":\"uri\",\"maxLength\":2048,\"type\":\"string\"}},\"required\":[\"bundleId\",\"algorithm\",\"transportUrl\",\"transportToken\",\"expectedSha256\",\"expectedSizeBytes\",\"expiresAt\"],\"title\":\"Bundle descriptor\",\"type\":\"object\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"completionHint\":{\"description\":\"Operator-facing text describing how to complete the download. Advisory: a producer must not parse it or derive behaviour from it, and a recipient must not put a secret in it.\",\"maxLength\":1024,\"type\":\"string\"},\"descriptor\":{\"$ref\":\"#/$defs/BundleDescriptor\",\"description\":\"Where the bytes are, what they should be, and until when.\"},\"ext\":{\"$ref\":\"#/$defs/Ext\",\"description\":\"Ecosystem-defined extension members per SPEC.md §4.5.1.\"}},\"required\":[\"descriptor\"],\"title\":\"VTA Backup Initiate Export — response payload\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::TRANSPORT_UNAVAILABLE,
error_codes::WEAK_PASSWORD,
error_codes::UNSUPPORTED_ALGORITHM,
error_codes::TOO_MANY_OPEN_BUNDLES,
];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `vta/backup/initiate-export:transportUnavailable`
///
/// The recipient has no address at which it can publish the bytes, so it cannot produce a descriptor. Not a fault in the request — see Transport preconditions.
///
/// Declared `retryable: false`.
pub const TRANSPORT_UNAVAILABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:transportUnavailable",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/backup/initiate-export:weakPassword`
///
/// The password is shorter than the recipient's floor. Refused before any state is serialized.
///
/// Declared `retryable: false`.
pub const WEAK_PASSWORD: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:weakPassword",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/backup/initiate-export:unsupportedAlgorithm`
///
/// The recipient does not implement the requested transport algorithm. The message names what it does implement.
///
/// Declared `retryable: false`.
pub const UNSUPPORTED_ALGORITHM: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:unsupportedAlgorithm",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/backup/initiate-export:tooManyOpenBundles`
///
/// This operator already holds the maximum number of live bundles. Abort one or wait for expiry.
///
/// Declared `retryable: true`.
pub const TOO_MANY_OPEN_BUNDLES: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/backup/initiate-export:tooManyOpenBundles",
retryable: true,
details_schema: ::core::option::Option::None,
};
}