Skip to main content

CaptureFailure

Enum CaptureFailure 

Source
pub enum CaptureFailure {
    Shadowed {
        environment: Option<PathBuf>,
    },
    InvalidPath {
        reason: String,
    },
    BodyNotJson {
        reason: String,
        content_type: Option<String>,
    },
    NoMatch,
    Ambiguous {
        count: usize,
        sample: Vec<String>,
    },
    NotAScalar {
        kind: &'static str,
    },
    HeaderNotFound {
        header: String,
        present: Vec<String>,
    },
}
Expand description

Why one entry of a capture block did not produce a value.

Typed rather than a bare string so a front-end can branch on it — and so the granularity the assertion JSON paths already draw (“not a valid JSON path” is a broken file, “the body is not JSON” is a fact about this response, “matched nothing” is a fact about the pair) survives into anything reading a run rather than being recoverable only by matching on prose. Display renders the wording, in core, so every front-end says the same thing about the same failure.

Variants§

§

Shadowed

The name is already defined by the active environment file. See the note on this variant’s message for why that is rejected rather than resolved in either direction.

Fields

§environment: Option<PathBuf>

The environment file that already defines the name, or None when the environment did not come from a file.

§

InvalidPath

The path is not a JSON path at all.

Fields

§reason: String
§

BodyNotJson

The response body did not parse as JSON, so there was nothing to query.

Fields

§reason: String

serde_json’s own message, position included.

§content_type: Option<String>

The response’s content-type, when it had one — a body with none at all is a different mistake from one that announced text/html.

§

NoMatch

The path is valid and the body is JSON, and the path selected nothing.

§

Ambiguous

The source selected more than one value, so there is no single value to bind the name to. Raised for a JSON path matching several values, and — the same philosophy applied to a second source — for a header capture whose name repeats in the response (Set-Cookie is the common case). See the module docs for why a capture does not resolve a repeated header by taking the first or last value, the way an assertion checking the same header does.

Fields

§count: usize
§sample: Vec<String>

The first few matches, rendered, for the message.

§

NotAScalar

The path selected exactly one value and that value has no text form a {{name}} could be replaced with: null, an array or an object.

Fields

§kind: &'static str

null, an array, an object.

§

HeaderNotFound

A header: capture named a header the response does not carry.

Fields

§header: String
§present: Vec<String>

The header names the response does carry, for the same reason a missing assertion header lists them: the answer is usually a casing or spelling difference, visible once both are on screen.

Trait Implementations§

Source§

impl Clone for CaptureFailure

Source§

fn clone(&self) -> CaptureFailure

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 CaptureFailure

Source§

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

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

impl Display for CaptureFailure

Source§

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

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

impl Eq for CaptureFailure

Source§

impl PartialEq for CaptureFailure

Source§

fn eq(&self, other: &CaptureFailure) -> 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 CaptureFailure

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

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> 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: 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> 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> 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, !>

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