pub struct ErrorPayload {
pub code: TrustTaskCode,
pub in_response_to: Option<InResponseTo>,
pub message: Option<String>,
pub retryable: bool,
pub retry_after: Option<DateTime<Utc>>,
pub details: Option<Value>,
}Expand description
The payload of a trust-task-error/0.5 document, per SPEC.md §8.2.
Exchange-level correlation is carried by the surrounding
TrustTask’s threadId; which document this error
reports on is carried here, by in_response_to.
Fields§
§code: TrustTaskCodeShort identifier for the failure category.
in_response_to: Option<InResponseTo>Identifies the Trust Task document this error reports on (SPEC.md §8.2).
threadId correlates the exchange for a party that saw the originating
request, and identifies nothing to anyone else. Without this, a retained
error names neither the specification the failure occurred under nor the
instance that triggered it — and for the standard codes of §8.3 there is
no other signal of origin at all.
SHOULD be populated in general, and MUST be where the error will
be retained, replayed, or relied upon beyond the original producer. The
document builders on TrustTask populate it for you.
message: Option<String>Human-readable description. Non-normative; intended for logs and operator UI.
retryable: boolWhether the producer MAY retry the original document. Per SPEC.md §8.4,
“retry” means re-sending bit-for-bit; a new document with a fresh id
is not a retry.
retry_after: Option<DateTime<Utc>>Earliest time at which the producer SHOULD retry. Meaningful only when
retryable is true.
details: Option<Value>Task-specific extension data. The shape is defined by the originating Trust Task specification (SPEC.md §8.5).
Implementations§
Source§impl ErrorPayload
impl ErrorPayload
Sourcepub fn new(code: impl Into<TrustTaskCode>) -> ErrorPayload
pub fn new(code: impl Into<TrustTaskCode>) -> ErrorPayload
Construct a minimal payload for code. retryable is initialized to
the code’s default per the §8.3 table (overridable via
with_retryable). All other members are absent.
Sourcepub fn about(
self,
type_uri: impl Into<String>,
id: Option<String>,
) -> ErrorPayload
pub fn about( self, type_uri: impl Into<String>, id: Option<String>, ) -> ErrorPayload
Name the document this error reports on (SPEC.md §8.2).
Prefer the builders on TrustTask, which populate
this from the request being rejected — including the §8.1 rule that the
id is omitted under identityMismatch. Use this directly only when
constructing a payload without the originating document in hand.
Sourcepub fn with_message(self, message: impl Into<String>) -> ErrorPayload
pub fn with_message(self, message: impl Into<String>) -> ErrorPayload
Attach a human-readable message.
Sourcepub fn with_retryable(self, retryable: bool) -> ErrorPayload
pub fn with_retryable(self, retryable: bool) -> ErrorPayload
Override the retryable flag (default is taken from
StandardCode::default_retryable).
Sourcepub fn with_retry_after(self, when: DateTime<Utc>) -> ErrorPayload
pub fn with_retry_after(self, when: DateTime<Utc>) -> ErrorPayload
Attach a retryAfter hint. Meaningful only when retryable is true.
Sourcepub fn with_details(self, details: Value) -> ErrorPayload
pub fn with_details(self, details: Value) -> ErrorPayload
Attach task-specific extension data.
Sourcepub fn effective_code(&self) -> StandardCode
pub fn effective_code(&self) -> StandardCode
Resolve this payload’s code to a StandardCode the consumer is
guaranteed to recognize, applying the SPEC §8.5 fallback:
unrecognized extension codes collapse to StandardCode::TaskFailed.
Standard codes are returned as-is.
Sourcepub fn should_retry_at(&self, now: DateTime<Utc>) -> bool
pub fn should_retry_at(&self, now: DateTime<Utc>) -> bool
Apply the SPEC §8.4 retry-semantics check.
Returns true only when:
retryableistrue, ANDretry_afteris either absent or already pastnow.
A false return means the producer MUST NOT retry yet (or at all,
when retryable is false). “Retry” here is the strict bit-for-bit
sense from SPEC §8.4 — issuing a new document with a fresh id is
always permitted regardless of this value.
Trait Implementations§
Source§impl Clone for ErrorPayload
impl Clone for ErrorPayload
Source§fn clone(&self) -> ErrorPayload
fn clone(&self) -> ErrorPayload
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ErrorPayload
impl Debug for ErrorPayload
Source§impl<'de> Deserialize<'de> for ErrorPayload
impl<'de> Deserialize<'de> for ErrorPayload
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorPayload, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorPayload, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for ErrorPayload
impl Display for ErrorPayload
impl Eq for ErrorPayload
Source§impl Error for ErrorPayload
impl Error for ErrorPayload
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<RejectReason> for ErrorPayload
impl From<RejectReason> for ErrorPayload
Source§fn from(reason: RejectReason) -> ErrorPayload
fn from(reason: RejectReason) -> ErrorPayload
Source§impl From<StandardCode> for ErrorPayload
impl From<StandardCode> for ErrorPayload
Source§fn from(code: StandardCode) -> ErrorPayload
fn from(code: StandardCode) -> ErrorPayload
Source§impl From<TrustTaskCode> for ErrorPayload
impl From<TrustTaskCode> for ErrorPayload
Source§fn from(code: TrustTaskCode) -> ErrorPayload
fn from(code: TrustTaskCode) -> ErrorPayload
Source§impl PartialEq for ErrorPayload
impl PartialEq for ErrorPayload
Source§impl Serialize for ErrorPayload
impl Serialize for ErrorPayload
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ErrorPayload
Auto Trait Implementations§
impl Freeze for ErrorPayload
impl RefUnwindSafe for ErrorPayload
impl Send for ErrorPayload
impl Sync for ErrorPayload
impl Unpin for ErrorPayload
impl UnsafeUnpin for ErrorPayload
impl UnwindSafe for ErrorPayload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<'de, T, C> DeserializeTyped<'de, C> for Twhere
T: Deserialize<'de>,
impl<'de, T, C> DeserializeTyped<'de, C> for Twhere
T: Deserialize<'de>,
fn deserialize_typed<S>(
_: &C,
deserializer: S,
) -> Result<T, <S as Deserializer<'de>>::Error>where
S: Deserializer<'de>,
impl<T, U> DeserializeTypedOwned<T> for Uwhere
U: for<'de> DeserializeTyped<'de, T>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T.