Skip to main content

DenialContext

Struct DenialContext 

Source
pub struct DenialContext {
    pub reason: DenialReason,
    pub source: Option<String>,
    pub attempted: Option<String>,
    pub expected: Option<Vec<String>>,
    pub hop_index: Option<u8>,
    pub cap: Option<u64>,
    pub actual: Option<u64>,
}
Expand description

Structured machine-parseable companion to error.message for recoverable denials.

The field is optional and additive on the public error envelope — every previously-shipped {code, message} envelope remains valid, and agents that ignore this struct continue to work. When present, it carries the concrete parameters an LLM agent can use to plan a recovery (e.g. “the redirect to evil.example.com was denied because it is not in the crossref allowlist”) without text-mining error.message.

§Wire shape

#[serde(deny_unknown_fields)]: forward-compatible field additions on the wire are forbidden by design — adding a field to this struct is a breaking change. This is why the type is not #[non_exhaustive] (per docs/PUBLIC_API.md §8): both production rules — Rust struct construction outside the crate AND wire-level extension — must agree.

All fields except reason are optional. Producers populate the fields relevant to the reason and leave the rest at None; consumers MUST tolerate any subset of fields being present. Optional fields are skipped on serialize but accepted as missing on deserialize via #[serde(default, skip_serializing_if = "Option::is_none")].

Self::expected is Option<Vec<String>> rather than Vec<String> so the producer can distinguish “this reason has no allowlist channel” (None → field absent on the wire) from “this is the explicit list of acceptable values, possibly empty” (Some(vec![])"expected":[] on the wire). The previous Vec<String> shape collapsed both states into “field omitted”, which an LLM agent could not safely disambiguate.

Mapping table: see ADR-0023 §4, plus the From<&HttpError> for Option<DenialContext> and From<&FetchError> for Option<DenialContext> impls in crate::http / crate::source.

Fields§

§reason: DenialReason

Closed-enum reason code; the only required field.

§source: Option<String>

Resolver source key (e.g. "crossref") when one is in scope.

§attempted: Option<String>

Concrete value the producer attempted (host, path, hex magic bytes, scheme prefix). Shape is reason-specific; consumers MUST treat it as opaque text.

§expected: Option<Vec<String>>

Allowlist entries / acceptable values. Option<Vec<String>> so the producer can distinguish “this reason has no allowlist channel” (None, field absent on the wire) from “this is the explicit list of acceptable values, possibly empty” (Some(vec![]), "expected":[] on the wire). The inner Vec<String> is used even when only one value is meaningful (e.g. Some(vec!["%PDF-".into()])) so the format does not have to flip when multiple values are acceptable.

§hop_index: Option<u8>

Redirect-chain hop position, 0-indexed. u8 because the chain is hard-capped at crate::http’s MAX_REDIRECTS (= 10) and any larger value indicates a bug.

§cap: Option<u64>

Size or rate cap value (e.g. PDF_MAX_BYTES).

§actual: Option<u64>

Observed value (e.g. response bytes when Self::cap is the byte cap, or row schema_version when Self::cap is the binary’s).

Trait Implementations§

Source§

impl Clone for DenialContext

Source§

fn clone(&self) -> DenialContext

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 DenialContext

Source§

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

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

impl<'de> Deserialize<'de> for DenialContext

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DenialContext

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DenialContext

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for DenialContext

Source§

impl StructuralPartialEq for DenialContext

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> 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> 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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> 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> 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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,