Function decart::decode_octocart
source · [−]Expand description
Decodes an Octocart, and returns the decoded JSON payload as a string.
Example
let file = std::fs::File::open("test_octocart.gif").unwrap();
let payload: String = decart::decode_octocart(file).unwrap();
You can deserialize this string as an OctoCart
:
use decart::OctoCart;
let cart: OctoCart = OctoCart::from_str(payload).unwrap();
Note that you can also deserialize from a file directly with from_file
:
use decart::*;
let cart: OctoCart = from_file("test_octocart.gif").unwrap();
Errors
Returns Err
if there is a GIF decoding error.