5 stable releases

2.0.1 Aug 31, 2021
1.0.2 Aug 31, 2021

#845 in Parser implementations

Download history 100/week @ 2023-12-18 74/week @ 2023-12-25 31/week @ 2024-01-01 47/week @ 2024-01-08 58/week @ 2024-01-15 55/week @ 2024-01-22 59/week @ 2024-01-29 72/week @ 2024-02-05 141/week @ 2024-02-12 183/week @ 2024-02-19 157/week @ 2024-02-26 116/week @ 2024-03-04 141/week @ 2024-03-11 123/week @ 2024-03-18 319/week @ 2024-03-25 420/week @ 2024-04-01

1,011 downloads per month
Used in 4 crates (2 directly)

MIT/Apache

15KB
152 lines

vcr-cassette

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.

Installation

$ cargo add vcr-cassette

Safety

This crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.7–4MB
~101K SLoC