Crate vcr_cassette

Crate vcr_cassette 

Source
Expand description

Serializer and deserializer for the VCR Cassette format.

§Examples

Given the following .json VCR Cassette recording:

{
    "http_interactions": [
        {
            "request": {
                "uri": "http://localhost:7777/foo",
                "body": "",
                "method": "get",
                "headers": { "Accept-Encoding": [ "identity" ] }
            },
            "response": {
                "body": "Hello foo",
                "http_version": "1.1",
                "status": { "code": 200, "message": "OK" },
                "headers": {
                    "Date": [ "Thu, 27 Oct 2011 06:16:31 GMT" ],
                    "Content-Type": [ "text/html;charset=utf-8" ],
                    "Content-Length": [ "9" ],
                }
            },
            "recorded_at": "Tue, 01 Nov 2011 04:58:44 GMT"
        },
    ],
    "recorded_with": "VCR 2.0.0"
}

We can deserialize it using serde_json:

use std::fs;
use vcr_cassette::Cassette;

let example = fs::read_to_string("tests/fixtures/example.json").unwrap();
let cassette: Cassette = serde_json::from_str(&example).unwrap();

To deserialize .yaml Cassette files use serde_yaml instead.

Re-exports§

pub use chrono;
pub use url;

Structs§

Body
A recorded HTTP Body.
Cassette
A sequence of recorded HTTP Request/Response pairs.
HttpInteraction
A single HTTP Request/Response pair.
Request
A recorded HTTP Request.
Response
A recorded HTTP Response.
Status
A recorded HTTP Status Code.

Enums§

Method
An HTTP method.
Version
The version of the HTTP protocol in use.

Type Aliases§

Headers
An HTTP Headers type.
RecorderId
An identifier of the library which created the recording.