trust-tasks-rs 0.21.21

Reference Rust library for the Trust Tasks framework — transport-agnostic, JSON-based descriptions of verifiable work between parties.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/backup/initiate-export`. Version: `1.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
    /// Error from a `TryFrom` or `FromStr` implementation.
    pub struct ConversionError(::std::borrow::Cow<'static, str>);
    impl ::std::error::Error for ConversionError {}
    impl ::std::fmt::Display for ConversionError {
        fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
            ::std::fmt::Display::fmt(&self.0, f)
        }
    }
    impl ::std::fmt::Debug for ConversionError {
        fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
            ::std::fmt::Debug::fmt(&self.0, f)
        }
    }
    impl From<&'static str> for ConversionError {
        fn from(value: &'static str) -> Self {
            Self(value.into())
        }
    }
    impl From<String> for ConversionError {
        fn from(value: String) -> Self {
            Self(value.into())
        }
    }
}
///The control-plane account of a bundle transfer: which algorithm, on what terms, until when. Exactly one of the two shapes — they are mutually exclusive, since StreamDescriptor requires `transportUrl` and `transportToken` and forbids `chunks`, and ChunkedDescriptor requires `chunks` and forbids both.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "BundleDescriptor",
///  "description": "The control-plane account of a bundle transfer: which algorithm, on what terms, until when. Exactly one of the two shapes — they are mutually exclusive, since StreamDescriptor requires `transportUrl` and `transportToken` and forbids `chunks`, and ChunkedDescriptor requires `chunks` and forbids both.",
///  "oneOf": [
///    {
///      "$ref": "#/definitions/StreamDescriptor"
///    },
///    {
///      "$ref": "#/definitions/ChunkedDescriptor"
///    }
///  ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
#[non_exhaustive]
pub enum BundleDescriptor {
    StreamDescriptor(StreamDescriptor),
    ChunkedDescriptor(ChunkedDescriptor),
}
impl ::std::convert::From<StreamDescriptor> for BundleDescriptor {
    fn from(value: StreamDescriptor) -> Self {
        Self::StreamDescriptor(value)
    }
}
impl ::std::convert::From<ChunkedDescriptor> for BundleDescriptor {
    fn from(value: ChunkedDescriptor) -> Self {
        Self::ChunkedDescriptor(value)
    }
}
///Handle for a bundle across its whole lifecycle. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence. Opaque: a producer quotes what it was given and must not derive, guess or enumerate one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "BundleId",
///  "description": "Handle for a bundle across its whole lifecycle. Recipient-generated and unguessable, which is what lets an unauthorized reference be answered as not-found without confirming existence. Opaque: a producer quotes what it was given and must not derive, guess or enumerate one.",
///  "type": "string",
///  "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BundleId(::std::string::String);
impl ::std::ops::Deref for BundleId {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<BundleId> for ::std::string::String {
    fn from(value: BundleId) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for BundleId {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
            ::std::sync::LazyLock::new(|| {
                ::regress::Regex::new(
                    "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                )
                .unwrap()
            });
        if PATTERN.find(value).is_none() {
            return Err(
                "doesn't match pattern \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\""
                    .into(),
            );
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for BundleId {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for BundleId {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for BundleId {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl<'de> ::serde::Deserialize<'de> for BundleId {
    fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
    where
        D: ::serde::Deserializer<'de>,
    {
        ::std::string::String::deserialize(deserializer)?
            .parse()
            .map_err(|e: self::error::ConversionError| {
                <D::Error as ::serde::de::Error>::custom(e.to_string())
            })
    }
}
///Number of chunks in the bundle, equal to ceil(expectedSizeBytes / chunkSize). Bounded at 4096 so that the manifest itself — one digest per chunk — fits in the single document that carries it under the same message-size reasoning as a chunk.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "ChunkCount",
///  "description": "Number of chunks in the bundle, equal to ceil(expectedSizeBytes / chunkSize). Bounded at 4096 so that the manifest itself — one digest per chunk — fits in the single document that carries it under the same message-size reasoning as a chunk.",
///  "type": "integer",
///  "maximum": 4096.0,
///  "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ChunkCount(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for ChunkCount {
    type Target = ::std::num::NonZeroU64;
    fn deref(&self) -> &::std::num::NonZeroU64 {
        &self.0
    }
}
impl ::std::convert::From<ChunkCount> for ::std::num::NonZeroU64 {
    fn from(value: ChunkCount) -> Self {
        value.0
    }
}
impl ::std::convert::From<::std::num::NonZeroU64> for ChunkCount {
    fn from(value: ::std::num::NonZeroU64) -> Self {
        Self(value)
    }
}
impl ::std::str::FromStr for ChunkCount {
    type Err = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
    fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
        Ok(Self(value.parse()?))
    }
}
impl ::std::convert::TryFrom<&str> for ChunkCount {
    type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
    fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<String> for ChunkCount {
    type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
    fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
        value.parse()
    }
}
impl ::std::fmt::Display for ChunkCount {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        self.0.fmt(f)
    }
}
/**
The terms of a `chunkedTrustTask` transfer, committed before any chunk moves. On export the recipient states them in the descriptor; on import the producer pre-commits them in the request and the recipient echoes them. Either way the manifest arrives in a document whose proof is REQUIRED, so the per-chunk digests are authenticated by the party that computed them and each chunk can be verified — and a single bad chunk re-fetched or refused — on arrival rather than only after reassembly.

Consistency rules JSON Schema cannot state: `chunkCount` MUST equal ceil(expectedSizeBytes / chunkSize) for the bundle the manifest describes, and `chunkDigests` MUST have exactly `chunkCount` items. A party receiving a manifest violating either MUST refuse it.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "ChunkManifest",
///  "description": "\nThe terms of a `chunkedTrustTask` transfer, committed before any chunk moves. On export the recipient states them in the descriptor; on import the producer pre-commits them in the request and the recipient echoes them. Either way the manifest arrives in a document whose proof is REQUIRED, so the per-chunk digests are authenticated by the party that computed them and each chunk can be verified — and a single bad chunk re-fetched or refused — on arrival rather than only after reassembly.\n\nConsistency rules JSON Schema cannot state: `chunkCount` MUST equal ceil(expectedSizeBytes / chunkSize) for the bundle the manifest describes, and `chunkDigests` MUST have exactly `chunkCount` items. A party receiving a manifest violating either MUST refuse it.",
///  "type": "object",
///  "required": [
///    "chunkCount",
///    "chunkDigests",
///    "chunkSize"
///  ],
///  "properties": {
///    "chunkCount": {
///      "$ref": "#/definitions/ChunkCount"
///    },
///    "chunkDigests": {
///      "description": "Digest of each chunk's raw bytes (not of its base64url encoding), in index order. Compared as decoded multihash bytes, never as encoded strings. sha2-256 is RECOMMENDED and MUST be implemented by every party; a party that does not implement the hash a digest names MUST treat the manifest as unverifiable rather than skip the check.",
///      "type": "array",
///      "items": {
///        "$ref": "#/definitions/DigestMultibase"
///      },
///      "maxItems": 4096,
///      "minItems": 1
///    },
///    "chunkSize": {
///      "$ref": "#/definitions/ChunkSize"
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ChunkManifest {
    #[serde(rename = "chunkCount")]
    pub chunk_count: ChunkCount,
    ///Digest of each chunk's raw bytes (not of its base64url encoding), in index order. Compared as decoded multihash bytes, never as encoded strings. sha2-256 is RECOMMENDED and MUST be implemented by every party; a party that does not implement the hash a digest names MUST treat the manifest as unverifiable rather than skip the check.
    #[serde(rename = "chunkDigests")]
    pub chunk_digests: ::std::vec::Vec<DigestMultibase>,
    #[serde(rename = "chunkSize")]
    pub chunk_size: ChunkSize,
}
impl ChunkManifest {
    pub fn builder() -> builder::ChunkManifest {
        Default::default()
    }
}
///Size in bytes of every chunk except the last, which carries the remainder and is between 1 and this value inclusive. The ceiling of 262144 (256 KiB) is normative and is derived in `vta/backup/initiate-export/1.1` under Chunked transfer: it is the largest power of two whose `get-chunk` or `put-chunk` document still fits a 1 MiB mediator message after base64url encoding of `data`, DIDComm authcrypt encoding, and two nested forward wrappers. The floor of 16384 keeps a 1 GiB bundle within `ChunkCount`'s ceiling at sizes a constrained transport can still choose.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "ChunkSize",
///  "description": "Size in bytes of every chunk except the last, which carries the remainder and is between 1 and this value inclusive. The ceiling of 262144 (256 KiB) is normative and is derived in `vta/backup/initiate-export/1.1` under Chunked transfer: it is the largest power of two whose `get-chunk` or `put-chunk` document still fits a 1 MiB mediator message after base64url encoding of `data`, DIDComm authcrypt encoding, and two nested forward wrappers. The floor of 16384 keeps a 1 GiB bundle within `ChunkCount`'s ceiling at sizes a constrained transport can still choose.",
///  "type": "integer",
///  "maximum": 262144.0,
///  "minimum": 16384.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ChunkSize(pub i64);
impl ::std::ops::Deref for ChunkSize {
    type Target = i64;
    fn deref(&self) -> &i64 {
        &self.0
    }
}
impl ::std::convert::From<ChunkSize> for i64 {
    fn from(value: ChunkSize) -> Self {
        value.0
    }
}
impl ::std::convert::From<i64> for ChunkSize {
    fn from(value: i64) -> Self {
        Self(value)
    }
}
impl ::std::str::FromStr for ChunkSize {
    type Err = <i64 as ::std::str::FromStr>::Err;
    fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
        Ok(Self(value.parse()?))
    }
}
impl ::std::convert::TryFrom<&str> for ChunkSize {
    type Error = <i64 as ::std::str::FromStr>::Err;
    fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<String> for ChunkSize {
    type Error = <i64 as ::std::str::FromStr>::Err;
    fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
        value.parse()
    }
}
impl ::std::fmt::Display for ChunkSize {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        self.0.fmt(f)
    }
}
///A descriptor for the `chunkedTrustTask` algorithm. Carries no address and no bearer token: every chunk moves in a Trust Task document whose sender the transport authenticates, so possession of a token would add nothing and would be one more secret to leak.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "ChunkedDescriptor",
///  "description": "A descriptor for the `chunkedTrustTask` algorithm. Carries no address and no bearer token: every chunk moves in a Trust Task document whose sender the transport authenticates, so possession of a token would add nothing and would be one more secret to leak.",
///  "type": "object",
///  "required": [
///    "algorithm",
///    "bundleId",
///    "chunks",
///    "expectedSha256",
///    "expectedSizeBytes",
///    "expiresAt"
///  ],
///  "properties": {
///    "algorithm": {
///      "description": "Discriminates this shape from StreamDescriptor.",
///      "type": "string",
///      "enum": [
///        "chunkedTrustTask"
///      ]
///    },
///    "bundleId": {
///      "$ref": "#/definitions/BundleId"
///    },
///    "chunks": {
///      "$ref": "#/definitions/ChunkManifest"
///    },
///    "expectedSha256": {
///      "$ref": "#/definitions/ExpectedSha256"
///    },
///    "expectedSizeBytes": {
///      "$ref": "#/definitions/ExpectedSizeBytes"
///    },
///    "expiresAt": {
///      "$ref": "#/definitions/ExpiresAt"
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ChunkedDescriptor {
    ///Discriminates this shape from StreamDescriptor.
    pub algorithm: ChunkedDescriptorAlgorithm,
    #[serde(rename = "bundleId")]
    pub bundle_id: BundleId,
    pub chunks: ChunkManifest,
    #[serde(rename = "expectedSha256")]
    pub expected_sha256: ExpectedSha256,
    #[serde(rename = "expectedSizeBytes")]
    pub expected_size_bytes: ExpectedSizeBytes,
    #[serde(rename = "expiresAt")]
    pub expires_at: ExpiresAt,
}
impl ChunkedDescriptor {
    pub fn builder() -> builder::ChunkedDescriptor {
        Default::default()
    }
}
///Discriminates this shape from StreamDescriptor.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Discriminates this shape from StreamDescriptor.",
///  "type": "string",
///  "enum": [
///    "chunkedTrustTask"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
#[non_exhaustive]
pub enum ChunkedDescriptorAlgorithm {
    #[serde(rename = "chunkedTrustTask")]
    ChunkedTrustTask,
}
impl ::std::fmt::Display for ChunkedDescriptorAlgorithm {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::ChunkedTrustTask => f.write_str("chunkedTrustTask"),
        }
    }
}
impl ::std::str::FromStr for ChunkedDescriptorAlgorithm {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "chunkedTrustTask" => Ok(Self::ChunkedTrustTask),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for ChunkedDescriptorAlgorithm {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for ChunkedDescriptorAlgorithm {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for ChunkedDescriptorAlgorithm {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
/**
A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.

Multihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.

This definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.

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