Crates.io | pickled |
lib.rs | pickled |
version | 1.2.0 |
source | src |
created_at | 2024-01-03 04:07:24.251819 |
updated_at | 2024-01-03 04:07:24.251819 |
description | A serde-based serialization library for Python's pickle format |
homepage | |
repository | https://github.com/landaire/pickled |
max_upload_size | |
id | 1086984 |
size | 598,573 |
This is a fork of https://crates.io/crates/serde-pickle with support for recursive data structures and variantly
support for Value
types to make working with pickled data easier.
THIS CRATE IS NOT INTENDED FOR WIDE USE, AND I MAKE NO GUARANTEES ABOUT BEING A GOOD PROJECT MAINTAINER (although I will not be evil, I just cannot guarantee that I can support this crate)
This crate is a Rust library for parsing and generating Python pickle streams. It is built upon Serde, a high performance generic serialization framework.
This crate works with Cargo and can be found on
crates.io with a Cargo.toml
like:
[dependencies]
serde = "1.0"
pickled = "1.0"
Minimum supported Rust version is 1.41.1.
As with other serde serialization implementations, this library provides toplevel functions for simple en/decoding of supported objects.
Example:
use std::collections::BTreeMap;
fn main() {
let mut map = BTreeMap::new();
map.insert("x".to_string(), 1.0);
map.insert("y".to_string(), 2.0);
// Serialize the map into a pickle stream.
// The second argument are serialization options.
let serialized = pickled::to_vec(&map, Default::default()).unwrap();
// Deserialize the pickle stream back into a map.
// Because we compare it to the original `map` below, Rust infers
// the type of `deserialized` and lets serde work its magic.
// The second argument are additional deserialization options.
let deserialized = pickled::from_slice(&serialized, Default::default()).unwrap();
assert_eq!(map, deserialized);
}
Serializing and deserializing structs and enums that implement the
serde-provided traits is supported, and works analogous to other crates
(using serde_derive
).