#[non_exhaustive]pub enum PayloadPolicy<'a, V>where
V: PayloadValidator + ?Sized,{
Validate(&'a V),
AcceptUnvalidated,
}Expand description
How consume_inbound performs SPEC.md §7.2 item 2 — payload-schema
validation.
Read this before reaching for AcceptUnvalidated.
In this library, item 2 is mostly already done by the time you hold a
TrustTask<P>: deserializing into the generated types enforces required
members, member types, additionalProperties: false, and the pattern /
minLength constraints typify expresses as validating newtypes. A
document that got this far has cleared all of that.
What it has not cleared is everything typify cannot express in a Rust
type — minProperties, minItems on an optional array, conditional
subschemas. That residue is what Validate catches, and
it is why the choice is a required argument rather than a default: a
consumer should decide knowingly whether that residue matters to it, not
discover later that it never checked.
(The TypeScript binding is in a different position entirely — its types are erased at runtime, so nothing is enforced without a validator. Both libraries take the policy as a required argument so the two reach the same verdict on the same document.)
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Validate(&'a V)
Validate doc.payload against Payload::PAYLOAD_SCHEMA using V.
Failures map to malformedRequest per §7.2 item 2.
Where the payload type carries no schema (PAYLOAD_SCHEMA is None,
i.e. the hand-modelled trust-task-error) there is nothing to check
and the document passes: the Rust type it deserialized into is itself
the constraint.
AcceptUnvalidated
Accept the payload on the strength of deserialization alone, without the residual schema check.
Defensible — deserialization is a real check here, not a formality — but it is a decision, and this names it.
This variant carries no validator, so nothing pins V. Write it as
PayloadPolicy::<NoValidator>::AcceptUnvalidated.
Auto Trait Implementations§
impl<'a, V> Freeze for PayloadPolicy<'a, V>
impl<'a, V> RefUnwindSafe for PayloadPolicy<'a, V>
impl<'a, V> Send for PayloadPolicy<'a, V>
impl<'a, V> Sync for PayloadPolicy<'a, V>
impl<'a, V> Unpin for PayloadPolicy<'a, V>
impl<'a, V> UnsafeUnpin for PayloadPolicy<'a, V>
impl<'a, V> UnwindSafe for PayloadPolicy<'a, V>
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> 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.