Skip to main content

RejectReason

Enum RejectReason 

Source
pub enum RejectReason {
Show 14 variants MalformedRequest { reason: String, }, UnsupportedType { type_uri: String, }, UnsupportedVersion { type_uri: String, }, Expired { expires_at: DateTime<Utc>, }, Stale { detail: StaleReason, }, IdConflict, ProofRequired, ProofInvalid { reason: String, }, PermissionDenied { reason: String, }, WrongRecipient { in_band: String, expected: String, }, IdentityMismatch(ConsistencyError), TaskFailed { reason: String, details: Option<Value>, }, Unavailable { retry_after: Option<DateTime<Utc>>, }, InternalError { reason: String, },
}
Expand description

Typed rejection conditions a conforming consumer raises while applying SPEC.md §7.2.

Each variant carries the context needed to render a meaningful operator message and maps to a single StandardCode from §8.3. The From impl produces an ErrorPayload with the matching code, retryable default, and a message derived from the variant’s fields.

Use this on the consumer side to turn ?-propagated errors from resolve_parties / validate_basic / your own task logic into a well-formed error response.

Variants§

§

MalformedRequest

The document did not validate against the framework or payload schema.

Fields

§reason: String

Human-readable explanation, surfaced as message in the response.

§

UnsupportedType

The consumer does not implement this type URI.

Fields

§type_uri: String

The unsupported Type URI as it appeared in the document.

§

UnsupportedVersion

The consumer recognizes the type but not at this MAJOR.MINOR.

Fields

§type_uri: String

The unsupported Type URI as it appeared in the document.

§

Expired

The document’s expiresAt was in the past.

Fields

§expires_at: DateTime<Utc>

The expiry timestamp carried in the rejected document.

§

Stale

The document falls outside the consumer’s acceptance window (SPEC.md §7.2, Bounding the record) — either because its issuedAt is older than the window, or because it carries no timestamp the consumer can place in one.

Reported as expired: §8.3 defines no separate code, and the window is the consumer’s own bound on when it is still willing to act, which is what expired means to the producer.

Fields

§detail: StaleReason

Which of the two window failures occurred. For the operator’s log; both render the same wire message.

§

IdConflict

The document’s id matches one the consumer has already accepted, but its content differs (SPEC.md §7.2 item 11).

The later document MUST NOT be treated as a retry of the original.

§

ProofRequired

A proof was required by the spec or consumer policy but was missing.

§

ProofInvalid

A proof was present but failed verification.

Fields

§reason: String

Human-readable explanation, surfaced as message.

§

PermissionDenied

The requesting party is not authorized to invoke this task.

Fields

§reason: String

Human-readable explanation, surfaced as message.

§

WrongRecipient

The document’s recipient is set but does not identify the consumer.

Fields

§in_band: String

Value carried by the document’s recipient member.

§expected: String

VID of the consumer that received the document.

§

IdentityMismatch(ConsistencyError)

An in-band party identity contradicts the transport-derived value.

§

TaskFailed

The task was attempted but could not be completed.

Fields

§reason: String

Human-readable explanation, surfaced as message.

§details: Option<Value>

Optional spec-defined extension data; carried verbatim into ErrorPayload::details.

§

Unavailable

The consumer is temporarily unable to process the task.

Fields

§retry_after: Option<DateTime<Utc>>

Optional retry-after hint, surfaced as retryAfter.

§

InternalError

The consumer encountered an unexpected internal failure.

Fields

§reason: String

Human-readable explanation, surfaced as message.

Implementations§

Source§

impl RejectReason

Source

pub fn code(&self) -> StandardCode

The StandardCode that corresponds to this rejection.

Source

pub fn wire_message(&self) -> String

Message safe to attach to a wire-serialised ErrorPayload.

SPEC.md §8.1 (final paragraph) and §10.4 require error-response messages to be free of consumer-side authentication context. The Display implementation (and to_string()) is intentionally chatty for diagnostic purposes — it names both the in-band and the transport-authenticated identities under Self::IdentityMismatch and the consumer’s own VID under Self::WrongRecipient, which makes log lines actionable but is exactly the identity oracle a wire-exposed message must not provide.

Variants whose Display is already consumer-side-neutral (Expired, ProofRequired, …) return the same string the Display would. The variants that would otherwise leak consumer-side state return a sanitised constant.

§ProofInvalid is sanitised

SPEC §10.4 states the rule for identityMismatch and then generalises it: “the same principle applies to every standard code: error messages SHOULD be derived from the code identifier and the Trust Task specification’s public vocabulary, not from consumer-side authentication context.”

A ProofInvalid { reason } built from a verifier’s error text is exactly that context. Real strings a cryptosuite backend produces include resolve did:web:x: connection refused, verificationMethod … not present in DID document, and verificationMethod is controlled by {vm_did}, not the document issuer {issuer}. Returned on the wire to an unauthenticated sender — the proof did not verify, so the sender is by definition not authenticated — those answer questions the sender asked by choosing what to put in proof: which DIDs this consumer can reach, whether a resolver is up, and what a DID document it fetched contains. That is a resolver-reachability and DID-document oracle, free of charge and at the sender’s chosen rate.

The reason remains on the Display impl, which is where the operator reads it.

Source

pub fn malformed_from_serde(err: &Error) -> RejectReason

Build a malformedRequest from a serde_json failure without echoing the deserializer’s pointer into the document.

serde_json::Error::to_string() renders as, for example, missing field 'subject' at line 1 column 214 or unknown field 'admin', expected one of … — the member path, the offset, and sometimes the full set of expected members. On the wire that describes the consumer’s internal type layout to anyone willing to send malformed JSON, and the offsets describe how the consumer framed the body.

This maps the error to its category — which is what a producer can act on — and leaves the detail for the log. Transport bindings that deserialize a body themselves should use this rather than format!("{e}"), so one rule holds across the framework.

Trait Implementations§

Source§

impl Clone for RejectReason

Source§

fn clone(&self) -> RejectReason

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RejectReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for RejectReason

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for RejectReason

Source§

impl Error for RejectReason

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ConsistencyError> for RejectReason

Source§

fn from(source: ConsistencyError) -> RejectReason

Converts to this type from the input type.
Source§

impl From<RejectReason> for ErrorPayload

Source§

fn from(reason: RejectReason) -> ErrorPayload

Converts to this type from the input type.
Source§

impl From<ReplayGuardError> for RejectReason

Source§

fn from(_: ReplayGuardError) -> RejectReason

Converts to this type from the input type.
Source§

impl PartialEq for RejectReason

Source§

fn eq(&self, other: &RejectReason) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RejectReason

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> At for T

Source§

fn at<M>(self, metadata: M) -> Meta<T, M>

Wraps self inside a Meta<Self, M> using the given metadata. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BorrowStripped for T

Source§

fn stripped(&self) -> &Stripped<T>

Source§

impl<T> BorrowUnordered for T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T, C> FromWithContext<T, C> for T

Source§

fn from_with(value: T, _context: &C) -> T

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

Source§

fn into_with(self, context: &C) -> U

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ResourceProvider<()> for T

Source§

fn get_resource(&self) -> &()

Returns a reference to the resource of type T.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToOwned for T

Source§

type Owned = T

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = !

Source§

fn try_from_with( value: U, context: &C, ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

Source§

type Error = <U as TryFromWithContext<T, C>>::Error

Source§

fn try_into_with( self, context: &C, ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithContext for T
where T: ?Sized,

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>
where T: Sized,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more