Skip to main content

ResponseExt

Struct ResponseExt 

Source
pub struct ResponseExt(/* private fields */);
Expand description

Extended response wrapper with additional processing capabilities.

This structure wraps a reqwest::Response and provides additional methods for extracting and formatting response data according to filtering rules defined in response profiles.

Implementations§

Source§

impl ResponseExt

Source

pub fn into_inner(self) -> Response

Extracts the inner Response object.

§Returns

The wrapped reqwest::Response object.

Source

pub async fn get_text(self, profile: &ResponseProfile) -> Result<String>

Extracts formatted text from the response according to profile rules.

This method processes the HTTP response and formats it as text, applying any skip rules defined in the response profile for headers and body content.

§Arguments
  • profile - Response profile containing skip rules for headers and body
§Returns

A Result<String> containing the formatted response text, including status line, filtered headers, and filtered body content.

§Examples
use xdiff_live::config::{ResponseExt, ResponseProfile};

let profile = ResponseProfile {
    skip_headers: vec!["date".to_string(), "server".to_string()],
    skip_body: vec!["timestamp".to_string()],
};

let formatted_text = response_ext.get_text(&profile).await?;
println!("{}", formatted_text);
Source

pub fn get_header_keys(&self) -> Vec<String>

Extracts all header keys from the response.

This method returns a list of all header names present in the response, which can be useful for debugging or dynamic header processing.

§Returns

A vector of header names as strings.

§Examples
use xdiff_live::config::ResponseExt;

let header_keys = response_ext.get_header_keys();
println!("Response headers: {:?}", header_keys);

Trait Implementations§

Source§

impl Debug for ResponseExt

Source§

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

Formats the value using the given formatter. Read more

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> ErasedDestructor for T
where T: 'static,

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

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