#[non_exhaustive]pub struct RecordedExchange {
pub method: String,
pub path: String,
pub status: u16,
pub request: Option<Value>,
pub response: Value,
pub headers: Vec<(String, String)>,
}Expand description
One recorded HTTP exchange. Preserved on disk as one JSONL line.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.method: StringHTTP method (GET, POST, etc.).
path: StringURL path (e.g. /v1/messages).
status: u16HTTP status code returned.
request: Option<Value>Decoded JSON request body, or None if the original request had
no body. Used as a matching constraint in
mount_cassette unless skip_request_match is set.
response: ValueDecoded JSON response body. Stored as Value so the cassette
stays human-readable and diffable.
headers: Vec<(String, String)>Optional response headers to set when serving (e.g.
request-id, retry-after). Defaults to none.
Implementations§
Source§impl RecordedExchange
impl RecordedExchange
Sourcepub fn new(
method: impl Into<String>,
path: impl Into<String>,
status: u16,
response: Value,
) -> Self
pub fn new( method: impl Into<String>, path: impl Into<String>, status: u16, response: Value, ) -> Self
Build a RecordedExchange with no request-body match constraint
and no extra response headers. Use the field setters to refine.
Sourcepub fn with_request(self, body: Value) -> Self
pub fn with_request(self, body: Value) -> Self
Add a request-body match constraint.
Trait Implementations§
Source§impl Clone for RecordedExchange
impl Clone for RecordedExchange
Source§fn clone(&self) -> RecordedExchange
fn clone(&self) -> RecordedExchange
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RecordedExchange
impl Debug for RecordedExchange
Source§impl<'de> Deserialize<'de> for RecordedExchange
impl<'de> Deserialize<'de> for RecordedExchange
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RecordedExchange
impl RefUnwindSafe for RecordedExchange
impl Send for RecordedExchange
impl Sync for RecordedExchange
impl Unpin for RecordedExchange
impl UnsafeUnpin for RecordedExchange
impl UnwindSafe for RecordedExchange
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
Mutably borrows from an owned value. Read more