trust-tasks-rs 0.8.0

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
//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `trust-task-control`. Version: `0.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 task-control request defined at SPEC.md §12: a producer withdrawing, pausing, or resuming work a consumer has already accepted.

This is a REQUEST, not a response. A consumer that stops work on its own initiative does not send one of these — it returns a trust-task-error carrying `cancelled`, so that a withdrawal and a refusal remain distinguishable to every party and to any auditor reading the retained documents afterwards.

The operation takes effect through SPEC.md §7.2 item 12: a valid, authorized control operation is one of the conditions a consumer re-evaluates immediately before each irreversible or externally visible effect. There is no separate race protocol.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "$id": "https://trusttasks.org/spec/trust-task-control/0.1",
///  "title": "Payload",
///  "description": "\nThe task-control request defined at SPEC.md §12: a producer withdrawing, pausing, or resuming work a consumer has already accepted.\n\nThis is a REQUEST, not a response. A consumer that stops work on its own initiative does not send one of these — it returns a trust-task-error carrying `cancelled`, so that a withdrawal and a refusal remain distinguishable to every party and to any auditor reading the retained documents afterwards.\n\nThe operation takes effect through SPEC.md §7.2 item 12: a valid, authorized control operation is one of the conditions a consumer re-evaluates immediately before each irreversible or externally visible effect. There is no separate race protocol.",
///  "type": "object",
///  "required": [
///    "operation",
///    "target"
///  ],
///  "properties": {
///    "ext": {
///      "description": "Vendor-namespaced extension data per SPEC.md §4.5.1. Every immediate child key MUST be a reverse-DNS prefix the producer controls.",
///      "type": "object"
///    },
///    "operation": {
///      "description": "\nThe control operation requested.\n\n`cancel` stops the task permanently: it is terminal, and a cancelled task MUST NOT be resumed, retried, or cancelled again (SPEC.md §12.3). `suspend` halts further effects while preserving the consumer's current execution state — it does not undo work already performed. `resume` continues a suspended task from the state the consumer holds; a consumer MUST NOT resume after the target document's `expiresAt` (SPEC.md §12.5).\n\nThis is a discriminating field. A consumer that does not recognize a value MUST reject the document rather than apply a default — silently downgrading an unrecognized operation to a known one would let a producer's intent be replaced by the consumer's guess.",
///      "enum": [
///        "cancel",
///        "suspend",
///        "resume"
///      ]
///    },
///    "reason": {
///      "description": "Human-readable explanation of why the operation was requested. Non-normative; intended for operator UI and audit records. A consumer MUST NOT condition its handling of the operation on this value.",
///      "type": "string"
///    },
///    "target": {
///      "description": "The specific Trust Task document this operation applies to. Per SPEC.md §12.2, `threadId`, `parentThreadId` and ceremony membership MUST NOT identify the target on their own: more than one document can occur in a single exchange or enactment.",
///      "type": "object",
///      "required": [
///        "id"
///      ],
///      "properties": {
///        "id": {
///          "description": "The `id` of the target Trust Task document. The sole identifying member.",
///          "type": "string",
///          "minLength": 1
///        },
///        "typeUri": {
///          "description": "The target document's `type`, including any `#request` fragment. RECOMMENDED. A consumer that holds the named `id` under a different specification can then detect the mismatch rather than acting on a coincidence of identifiers.",
///          "type": "string",
///          "format": "uri",
///          "minLength": 1
///        }
///      },
///      "additionalProperties": false
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Payload {
    ///Vendor-namespaced extension data per SPEC.md §4.5.1. Every immediate child key MUST be a reverse-DNS prefix the producer controls.
    #[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
    pub ext: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
    /**
    The control operation requested.

    `cancel` stops the task permanently: it is terminal, and a cancelled task MUST NOT be resumed, retried, or cancelled again (SPEC.md §12.3). `suspend` halts further effects while preserving the consumer's current execution state — it does not undo work already performed. `resume` continues a suspended task from the state the consumer holds; a consumer MUST NOT resume after the target document's `expiresAt` (SPEC.md §12.5).

    This is a discriminating field. A consumer that does not recognize a value MUST reject the document rather than apply a default — silently downgrading an unrecognized operation to a known one would let a producer's intent be replaced by the consumer's guess.*/
    pub operation: PayloadOperation,
    ///Human-readable explanation of why the operation was requested. Non-normative; intended for operator UI and audit records. A consumer MUST NOT condition its handling of the operation on this value.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub reason: ::std::option::Option<::std::string::String>,
    pub target: PayloadTarget,
}
/**
The control operation requested.

`cancel` stops the task permanently: it is terminal, and a cancelled task MUST NOT be resumed, retried, or cancelled again (SPEC.md §12.3). `suspend` halts further effects while preserving the consumer's current execution state — it does not undo work already performed. `resume` continues a suspended task from the state the consumer holds; a consumer MUST NOT resume after the target document's `expiresAt` (SPEC.md §12.5).

This is a discriminating field. A consumer that does not recognize a value MUST reject the document rather than apply a default — silently downgrading an unrecognized operation to a known one would let a producer's intent be replaced by the consumer's guess.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "\nThe control operation requested.\n\n`cancel` stops the task permanently: it is terminal, and a cancelled task MUST NOT be resumed, retried, or cancelled again (SPEC.md §12.3). `suspend` halts further effects while preserving the consumer's current execution state — it does not undo work already performed. `resume` continues a suspended task from the state the consumer holds; a consumer MUST NOT resume after the target document's `expiresAt` (SPEC.md §12.5).\n\nThis is a discriminating field. A consumer that does not recognize a value MUST reject the document rather than apply a default — silently downgrading an unrecognized operation to a known one would let a producer's intent be replaced by the consumer's guess.",
///  "enum": [
///    "cancel",
///    "suspend",
///    "resume"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum PayloadOperation {
    #[serde(rename = "cancel")]
    Cancel,
    #[serde(rename = "suspend")]
    Suspend,
    #[serde(rename = "resume")]
    Resume,
}
impl ::std::fmt::Display for PayloadOperation {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Cancel => f.write_str("cancel"),
            Self::Suspend => f.write_str("suspend"),
            Self::Resume => f.write_str("resume"),
        }
    }
}
impl ::std::str::FromStr for PayloadOperation {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "cancel" => Ok(Self::Cancel),
            "suspend" => Ok(Self::Suspend),
            "resume" => Ok(Self::Resume),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for PayloadOperation {
    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 PayloadOperation {
    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 PayloadOperation {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///The specific Trust Task document this operation applies to. Per SPEC.md §12.2, `threadId`, `parentThreadId` and ceremony membership MUST NOT identify the target on their own: more than one document can occur in a single exchange or enactment.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "The specific Trust Task document this operation applies to. Per SPEC.md §12.2, `threadId`, `parentThreadId` and ceremony membership MUST NOT identify the target on their own: more than one document can occur in a single exchange or enactment.",
///  "type": "object",
///  "required": [
///    "id"
///  ],
///  "properties": {
///    "id": {
///      "description": "The `id` of the target Trust Task document. The sole identifying member.",
///      "type": "string",
///      "minLength": 1
///    },
///    "typeUri": {
///      "description": "The target document's `type`, including any `#request` fragment. RECOMMENDED. A consumer that holds the named `id` under a different specification can then detect the mismatch rather than acting on a coincidence of identifiers.",
///      "type": "string",
///      "format": "uri",
///      "minLength": 1
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct PayloadTarget {
    ///The `id` of the target Trust Task document. The sole identifying member.
    pub id: PayloadTargetId,
    ///The target document's `type`, including any `#request` fragment. RECOMMENDED. A consumer that holds the named `id` under a different specification can then detect the mismatch rather than acting on a coincidence of identifiers.
    #[serde(
        rename = "typeUri",
        default,
        skip_serializing_if = "::std::option::Option::is_none"
    )]
    pub type_uri: ::std::option::Option<::std::string::String>,
}
///The `id` of the target Trust Task document. The sole identifying member.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "The `id` of the target Trust Task document. The sole identifying member.",
///  "type": "string",
///  "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadTargetId(::std::string::String);
impl ::std::ops::Deref for PayloadTargetId {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<PayloadTargetId> for ::std::string::String {
    fn from(value: PayloadTargetId) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for PayloadTargetId {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() < 1usize {
            return Err("shorter than 1 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for PayloadTargetId {
    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 PayloadTargetId {
    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 PayloadTargetId {
    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 PayloadTargetId {
    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())
            })
    }
}
///What the consumer did. The `outcome` is the load-bearing member: it is what tells the producer whether a compensating action is required, since SPEC.md §12.4 declines to require rollback.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "Response",
///  "description": "What the consumer did. The `outcome` is the load-bearing member: it is what tells the producer whether a compensating action is required, since SPEC.md §12.4 declines to require rollback.",
///  "type": "object",
///  "required": [
///    "operation",
///    "outcome",
///    "target"
///  ],
///  "properties": {
///    "effects": {
///      "description": "What was created, changed, disclosed, or exercised before the operation took hold. A consumer MUST populate this where `outcome` is `appliedWithEffects` or `alreadyCompleted` — a producer cannot decide whether to compensate without it — and the specification's Conformance section carries that requirement normatively. It is not expressed as a conditional schema because the registry's Rust code generator does not support if/then/else. The framework does not constrain how a task describes its own effects.",
///      "type": "array",
///      "items": {
///        "type": "object",
///        "required": [
///          "description"
///        ],
///        "properties": {
///          "description": {
///            "description": "Human-readable statement of the effect that occurred.",
///            "type": "string",
///            "minLength": 1
///          },
///          "ref": {
///            "description": "An identifier for the effect where one exists — a credential id, a record identifier, a transaction reference — so a compensating task can name it.",
///            "type": "string"
///          },
///          "reversible": {
///            "description": "Whether the consumer believes this effect can be compensated by a further Trust Task. Advisory. Absent means unknown, which a producer SHOULD treat as no weaker than `false`.",
///            "type": "boolean"
///          }
///        },
///        "additionalProperties": false
///      }
///    },
///    "ext": {
///      "description": "Vendor-namespaced extension data per SPEC.md §4.5.1.",
///      "type": "object"
///    },
///    "operation": {
///      "description": "Echoed from the request, so the response is self-describing when retained apart from it.",
///      "enum": [
///        "cancel",
///        "suspend",
///        "resume"
///      ]
///    },
///    "outcome": {
///      "description": "\n`applied` — the operation took effect and NO irreversible or externally visible effect had occurred. The only outcome that means the task left no trace.\n\n`appliedWithEffects` — the operation took effect, but effects had already occurred before it did. `effects` describes them. A consumer MUST NOT report `applied` in this case (SPEC.md §12.3).\n\n`alreadyCompleted` — the task finished before the control document was processed. Not a cancellation; whether to compensate is the producer's own decision.\n\n`unknownTask` — the consumer holds no record of the target `id`, either because it never received it or because its acceptance window has lapsed. A consumer that records the operation as a tombstone against a not-yet-arrived document reports `applied`, not this.",
///      "enum": [
///        "applied",
///        "appliedWithEffects",
///        "alreadyCompleted",
///        "unknownTask"
///      ]
///    },
///    "target": {
///      "description": "Echoed from the request.",
///      "type": "object",
///      "required": [
///        "id"
///      ],
///      "properties": {
///        "id": {
///          "type": "string",
///          "minLength": 1
///        },
///        "typeUri": {
///          "type": "string",
///          "format": "uri",
///          "minLength": 1
///        }
///      },
///      "additionalProperties": false
///    }
///  },
///  "additionalProperties": false,
///  "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Response {
    ///What was created, changed, disclosed, or exercised before the operation took hold. A consumer MUST populate this where `outcome` is `appliedWithEffects` or `alreadyCompleted` — a producer cannot decide whether to compensate without it — and the specification's Conformance section carries that requirement normatively. It is not expressed as a conditional schema because the registry's Rust code generator does not support if/then/else. The framework does not constrain how a task describes its own effects.
    #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
    pub effects: ::std::vec::Vec<ResponseEffectsItem>,
    ///Vendor-namespaced extension data per SPEC.md §4.5.1.
    #[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
    pub ext: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
    ///Echoed from the request, so the response is self-describing when retained apart from it.
    pub operation: ResponseOperation,
    /**
    `applied` — the operation took effect and NO irreversible or externally visible effect had occurred. The only outcome that means the task left no trace.

    `appliedWithEffects` — the operation took effect, but effects had already occurred before it did. `effects` describes them. A consumer MUST NOT report `applied` in this case (SPEC.md §12.3).

    `alreadyCompleted` — the task finished before the control document was processed. Not a cancellation; whether to compensate is the producer's own decision.

    `unknownTask` — the consumer holds no record of the target `id`, either because it never received it or because its acceptance window has lapsed. A consumer that records the operation as a tombstone against a not-yet-arrived document reports `applied`, not this.*/
    pub outcome: ResponseOutcome,
    pub target: ResponseTarget,
}
///`ResponseEffectsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "type": "object",
///  "required": [
///    "description"
///  ],
///  "properties": {
///    "description": {
///      "description": "Human-readable statement of the effect that occurred.",
///      "type": "string",
///      "minLength": 1
///    },
///    "ref": {
///      "description": "An identifier for the effect where one exists — a credential id, a record identifier, a transaction reference — so a compensating task can name it.",
///      "type": "string"
///    },
///    "reversible": {
///      "description": "Whether the consumer believes this effect can be compensated by a further Trust Task. Advisory. Absent means unknown, which a producer SHOULD treat as no weaker than `false`.",
///      "type": "boolean"
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ResponseEffectsItem {
    ///Human-readable statement of the effect that occurred.
    pub description: ResponseEffectsItemDescription,
    ///An identifier for the effect where one exists — a credential id, a record identifier, a transaction reference — so a compensating task can name it.
    #[serde(
        rename = "ref",
        default,
        skip_serializing_if = "::std::option::Option::is_none"
    )]
    pub ref_: ::std::option::Option<::std::string::String>,
    ///Whether the consumer believes this effect can be compensated by a further Trust Task. Advisory. Absent means unknown, which a producer SHOULD treat as no weaker than `false`.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub reversible: ::std::option::Option<bool>,
}
///Human-readable statement of the effect that occurred.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Human-readable statement of the effect that occurred.",
///  "type": "string",
///  "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseEffectsItemDescription(::std::string::String);
impl ::std::ops::Deref for ResponseEffectsItemDescription {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<ResponseEffectsItemDescription> for ::std::string::String {
    fn from(value: ResponseEffectsItemDescription) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for ResponseEffectsItemDescription {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() < 1usize {
            return Err("shorter than 1 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for ResponseEffectsItemDescription {
    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 ResponseEffectsItemDescription {
    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 ResponseEffectsItemDescription {
    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 ResponseEffectsItemDescription {
    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())
            })
    }
}
///Echoed from the request, so the response is self-describing when retained apart from it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Echoed from the request, so the response is self-describing when retained apart from it.",
///  "enum": [
///    "cancel",
///    "suspend",
///    "resume"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum ResponseOperation {
    #[serde(rename = "cancel")]
    Cancel,
    #[serde(rename = "suspend")]
    Suspend,
    #[serde(rename = "resume")]
    Resume,
}
impl ::std::fmt::Display for ResponseOperation {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Cancel => f.write_str("cancel"),
            Self::Suspend => f.write_str("suspend"),
            Self::Resume => f.write_str("resume"),
        }
    }
}
impl ::std::str::FromStr for ResponseOperation {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "cancel" => Ok(Self::Cancel),
            "suspend" => Ok(Self::Suspend),
            "resume" => Ok(Self::Resume),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for ResponseOperation {
    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 ResponseOperation {
    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 ResponseOperation {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
/**
`applied` — the operation took effect and NO irreversible or externally visible effect had occurred. The only outcome that means the task left no trace.

`appliedWithEffects` — the operation took effect, but effects had already occurred before it did. `effects` describes them. A consumer MUST NOT report `applied` in this case (SPEC.md §12.3).

`alreadyCompleted` — the task finished before the control document was processed. Not a cancellation; whether to compensate is the producer's own decision.

`unknownTask` — the consumer holds no record of the target `id`, either because it never received it or because its acceptance window has lapsed. A consumer that records the operation as a tombstone against a not-yet-arrived document reports `applied`, not this.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "\n`applied` — the operation took effect and NO irreversible or externally visible effect had occurred. The only outcome that means the task left no trace.\n\n`appliedWithEffects` — the operation took effect, but effects had already occurred before it did. `effects` describes them. A consumer MUST NOT report `applied` in this case (SPEC.md §12.3).\n\n`alreadyCompleted` — the task finished before the control document was processed. Not a cancellation; whether to compensate is the producer's own decision.\n\n`unknownTask` — the consumer holds no record of the target `id`, either because it never received it or because its acceptance window has lapsed. A consumer that records the operation as a tombstone against a not-yet-arrived document reports `applied`, not this.",
///  "enum": [
///    "applied",
///    "appliedWithEffects",
///    "alreadyCompleted",
///    "unknownTask"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum ResponseOutcome {
    #[serde(rename = "applied")]
    Applied,
    #[serde(rename = "appliedWithEffects")]
    AppliedWithEffects,
    #[serde(rename = "alreadyCompleted")]
    AlreadyCompleted,
    #[serde(rename = "unknownTask")]
    UnknownTask,
}
impl ::std::fmt::Display for ResponseOutcome {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Applied => f.write_str("applied"),
            Self::AppliedWithEffects => f.write_str("appliedWithEffects"),
            Self::AlreadyCompleted => f.write_str("alreadyCompleted"),
            Self::UnknownTask => f.write_str("unknownTask"),
        }
    }
}
impl ::std::str::FromStr for ResponseOutcome {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "applied" => Ok(Self::Applied),
            "appliedWithEffects" => Ok(Self::AppliedWithEffects),
            "alreadyCompleted" => Ok(Self::AlreadyCompleted),
            "unknownTask" => Ok(Self::UnknownTask),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for ResponseOutcome {
    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 ResponseOutcome {
    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 ResponseOutcome {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///Echoed from the request.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Echoed from the request.",
///  "type": "object",
///  "required": [
///    "id"
///  ],
///  "properties": {
///    "id": {
///      "type": "string",
///      "minLength": 1
///    },
///    "typeUri": {
///      "type": "string",
///      "format": "uri",
///      "minLength": 1
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ResponseTarget {
    pub id: ResponseTargetId,
    #[serde(
        rename = "typeUri",
        default,
        skip_serializing_if = "::std::option::Option::is_none"
    )]
    pub type_uri: ::std::option::Option<::std::string::String>,
}
///`ResponseTargetId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "type": "string",
///  "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseTargetId(::std::string::String);
impl ::std::ops::Deref for ResponseTargetId {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<ResponseTargetId> for ::std::string::String {
    fn from(value: ResponseTargetId) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for ResponseTargetId {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() < 1usize {
            return Err("shorter than 1 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for ResponseTargetId {
    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 ResponseTargetId {
    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 ResponseTargetId {
    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 ResponseTargetId {
    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())
            })
    }
}
impl crate::Payload for Payload {
    const TYPE_URI: &'static str = "https://trusttasks.org/spec/trust-task-control/0.1";
    const IS_PROOF_REQUIRED: bool = true;
    const IS_RECIPIENT_REQUIRED: bool = true;
}
impl crate::Payload for Response {
    const TYPE_URI: &'static str = "https://trusttasks.org/spec/trust-task-control/0.1#response";
    const IS_PROOF_REQUIRED: bool = true;
    const IS_RECIPIENT_REQUIRED: bool = true;
}
#[cfg(feature = "validate")]
impl crate::validate::ValidatedPayload for Payload {
    const SCHEMA_JSON: &'static str = "{\n  \"$defs\": {\n    \"Response\": {\n      \"$anchor\": \"response\",\n      \"additionalProperties\": false,\n      \"description\": \"What the consumer did. The `outcome` is the load-bearing member: it is what tells the producer whether a compensating action is required, since SPEC.md §12.4 declines to require rollback.\",\n      \"properties\": {\n        \"effects\": {\n          \"description\": \"What was created, changed, disclosed, or exercised before the operation took hold. A consumer MUST populate this where `outcome` is `appliedWithEffects` or `alreadyCompleted` — a producer cannot decide whether to compensate without it — and the specification's Conformance section carries that requirement normatively. It is not expressed as a conditional schema because the registry's Rust code generator does not support if/then/else. The framework does not constrain how a task describes its own effects.\",\n          \"items\": {\n            \"additionalProperties\": false,\n            \"properties\": {\n              \"description\": {\n                \"description\": \"Human-readable statement of the effect that occurred.\",\n                \"minLength\": 1,\n                \"type\": \"string\"\n              },\n              \"ref\": {\n                \"description\": \"An identifier for the effect where one exists — a credential id, a record identifier, a transaction reference — so a compensating task can name it.\",\n                \"type\": \"string\"\n              },\n              \"reversible\": {\n                \"description\": \"Whether the consumer believes this effect can be compensated by a further Trust Task. Advisory. Absent means unknown, which a producer SHOULD treat as no weaker than `false`.\",\n                \"type\": \"boolean\"\n              }\n            },\n            \"required\": [\n              \"description\"\n            ],\n            \"type\": \"object\"\n          },\n          \"type\": \"array\"\n        },\n        \"ext\": {\n          \"description\": \"Vendor-namespaced extension data per SPEC.md §4.5.1.\",\n          \"type\": \"object\"\n        },\n        \"operation\": {\n          \"description\": \"Echoed from the request, so the response is self-describing when retained apart from it.\",\n          \"enum\": [\n            \"cancel\",\n            \"suspend\",\n            \"resume\"\n          ]\n        },\n        \"outcome\": {\n          \"description\": \"`applied` — the operation took effect and NO irreversible or externally visible effect had occurred. The only outcome that means the task left no trace.\\n\\n`appliedWithEffects` — the operation took effect, but effects had already occurred before it did. `effects` describes them. A consumer MUST NOT report `applied` in this case (SPEC.md §12.3).\\n\\n`alreadyCompleted` — the task finished before the control document was processed. Not a cancellation; whether to compensate is the producer's own decision.\\n\\n`unknownTask` — the consumer holds no record of the target `id`, either because it never received it or because its acceptance window has lapsed. A consumer that records the operation as a tombstone against a not-yet-arrived document reports `applied`, not this.\",\n          \"enum\": [\n            \"applied\",\n            \"appliedWithEffects\",\n            \"alreadyCompleted\",\n            \"unknownTask\"\n          ]\n        },\n        \"target\": {\n          \"additionalProperties\": false,\n          \"description\": \"Echoed from the request.\",\n          \"properties\": {\n            \"id\": {\n              \"minLength\": 1,\n              \"type\": \"string\"\n            },\n            \"typeUri\": {\n              \"format\": \"uri\",\n              \"minLength\": 1,\n              \"type\": \"string\"\n            }\n          },\n          \"required\": [\n            \"id\"\n          ],\n          \"type\": \"object\"\n        }\n      },\n      \"required\": [\n        \"operation\",\n        \"target\",\n        \"outcome\"\n      ],\n      \"title\": \"Trust Task Control — response payload\",\n      \"type\": \"object\"\n    }\n  },\n  \"$id\": \"https://trusttasks.org/spec/trust-task-control/0.1\",\n  \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n  \"additionalProperties\": false,\n  \"description\": \"The task-control request defined at SPEC.md §12: a producer withdrawing, pausing, or resuming work a consumer has already accepted.\\n\\nThis is a REQUEST, not a response. A consumer that stops work on its own initiative does not send one of these — it returns a trust-task-error carrying `cancelled`, so that a withdrawal and a refusal remain distinguishable to every party and to any auditor reading the retained documents afterwards.\\n\\nThe operation takes effect through SPEC.md §7.2 item 12: a valid, authorized control operation is one of the conditions a consumer re-evaluates immediately before each irreversible or externally visible effect. There is no separate race protocol.\",\n  \"properties\": {\n    \"ext\": {\n      \"description\": \"Vendor-namespaced extension data per SPEC.md §4.5.1. Every immediate child key MUST be a reverse-DNS prefix the producer controls.\",\n      \"type\": \"object\"\n    },\n    \"operation\": {\n      \"description\": \"The control operation requested.\\n\\n`cancel` stops the task permanently: it is terminal, and a cancelled task MUST NOT be resumed, retried, or cancelled again (SPEC.md §12.3). `suspend` halts further effects while preserving the consumer's current execution state — it does not undo work already performed. `resume` continues a suspended task from the state the consumer holds; a consumer MUST NOT resume after the target document's `expiresAt` (SPEC.md §12.5).\\n\\nThis is a discriminating field. A consumer that does not recognize a value MUST reject the document rather than apply a default — silently downgrading an unrecognized operation to a known one would let a producer's intent be replaced by the consumer's guess.\",\n      \"enum\": [\n        \"cancel\",\n        \"suspend\",\n        \"resume\"\n      ]\n    },\n    \"reason\": {\n      \"description\": \"Human-readable explanation of why the operation was requested. Non-normative; intended for operator UI and audit records. A consumer MUST NOT condition its handling of the operation on this value.\",\n      \"type\": \"string\"\n    },\n    \"target\": {\n      \"additionalProperties\": false,\n      \"description\": \"The specific Trust Task document this operation applies to. Per SPEC.md §12.2, `threadId`, `parentThreadId` and ceremony membership MUST NOT identify the target on their own: more than one document can occur in a single exchange or enactment.\",\n      \"properties\": {\n        \"id\": {\n          \"description\": \"The `id` of the target Trust Task document. The sole identifying member.\",\n          \"minLength\": 1,\n          \"type\": \"string\"\n        },\n        \"typeUri\": {\n          \"description\": \"The target document's `type`, including any `#request` fragment. RECOMMENDED. A consumer that holds the named `id` under a different specification can then detect the mismatch rather than acting on a coincidence of identifiers.\",\n          \"format\": \"uri\",\n          \"minLength\": 1,\n          \"type\": \"string\"\n        }\n      },\n      \"required\": [\n        \"id\"\n      ],\n      \"type\": \"object\"\n    }\n  },\n  \"required\": [\n    \"operation\",\n    \"target\"\n  ],\n  \"title\": \"Trust Task Control — payload\",\n  \"type\": \"object\"\n}\n";
}