Code Monkey home page Code Monkey logo

serde-pickle's Introduction

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.0"

Requirements

Minimum supported Rust version is 1.41.1.

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).

serde-pickle's People

Contributors

aidanhs avatar birkenfeld avatar jbakker-atmind avatar m-dewanchand avatar waymost avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.