Struct rvcr::VCRMiddleware

source ·
pub struct VCRMiddleware { /* private fields */ }
Expand description

Pluggable VCR middleware for record-and-replay for reqwest items

Implementations§

source§

impl VCRMiddleware

Implements boilerplate for converting between vcr_cassette and reqwest structures.

Carries methods to find response in a cassette, and to record an interaction.

source

pub fn with_mode(self, mode: VCRMode) -> Self

Adjust mode in the middleware and return it

source

pub fn with_modify_request<F>(self, modifier: F) -> Self
where F: Fn(&mut Request) + Send + Sync + 'static,

source

pub fn with_modify_response<F>(self, modifier: F) -> Self
where F: Fn(&mut Response) + Send + Sync + 'static,

Adjust search behavior for responses

source

pub fn with_path(self, path: impl Into<PathBuf>) -> Self

Adjust path in the middleware and return it

source

pub fn with_rich_diff(self, rich_diff: bool) -> Self

Adjust rich diff in the middleware and return it

Trait Implementations§

source§

impl Drop for VCRMiddleware

Save cassette interactions after the run

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<Cassette> for VCRMiddleware

Create middleware instance from Cassette

source§

fn from(cassette: Cassette) -> Self

Converts to this type from the input type.
source§

impl Middleware for VCRMiddleware

Reqwest middleware implementation

It receives request, converts it to internal VCR format, and saves data in the internal.

source§

fn handle<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, req: Request, extensions: &'life1 mut Extensions, next: Next<'life2> ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Invoked with a request before sending it. If you want to continue processing the request, you should explicitly call next.run(req, extensions). Read more
source§

impl TryFrom<PathBuf> for VCRMiddleware

Load VCR cassette for filesystem For simplicity, support JSON format only for now

source§

fn try_from(pb: PathBuf) -> Result<Self, Self::Error>

Performs the conversion.
§

type Error = String

The type returned in the event of a conversion error.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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