MCPcopy Index your code
hub / github.com/birkenfeld/serde-pickle

github.com/birkenfeld/serde-pickle @v1.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.0 ↗ · + Follow
265 symbols 616 edges 14 files 55 documented · 21% updated 19mo ago★ 2247 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Serde Pickle Serialization Library

Build Status Latest Version

Documentation

This crate is a Rust library for parsing and generating Python pickle streams. It is built upon Serde, a high performance generic serialization framework.

Installation

This crate works with Cargo and can be found on crates.io with a Cargo.toml like:

[dependencies]
serde = "1.0"
serde-pickle = "1.1"

Requirements

Minimum supported Rust version is 1.63.0.

Usage

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 = serde_pickle::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 = serde_pickle::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).

Core symbols most depended-on inside this repo

write_opcode
called by 75
src/ser.rs
pop
called by 40
src/de.rs
error
called by 26
src/de.rs
deserialize
called by 16
src/value_impls.rs
value_from_slice
called by 12
src/de.rs
pop_mark
called by 11
src/de.rs
serialize_str
called by 10
src/ser.rs
resolve
called by 10
src/de.rs

Shape

Method 178
Function 53
Class 26
Enum 8

Languages

Rust97%
Python3%

Modules by API surface

src/value_impls.rs73 symbols
src/de.rs71 symbols
src/ser.rs52 symbols
test/mod.rs25 symbols
src/value.rs13 symbols
benches/benchmark.rs10 symbols
test/data/generate.py8 symbols
test/arby.rs7 symbols
src/error.rs5 symbols
examples/pickle.rs1 symbols

For agents

$ claude mcp add serde-pickle \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact