Giter VIP home page Giter VIP logo

serde-rlp's Introduction

serde-rlp

Crates.io Build Status Docs.rs

Ethereum's RLP encoding implemented as a Serde data format

This code is part of clarity - an effort to implement lightweight Ethereum transaction signing. WIP.

Releasing

To release new version of serde-rlp do the following steps:

# Do a signed tag for new version with annotation "YYYY-MM-DD, Version v$VERSION"
git tag v1.0.0 -a -s "2018-09-04, Version v1.0.0"
git push origin --follow-tags

Examples

You should be able to use this crate same way as you'd use other serialization formats in serde.

Serialize

The key to serialization is serde_rlp::ser::to_bytes which does the magic.

extern crate serde_rlp;
use serde_rlp::ser::to_bytes;

// Basic key values
let data = vec![vec!["key1", "value1"], vec!["key2", "value2"]];
let bytes = to_bytes(&data).expect("Unable to serialize data");
println!("Serialized data: {:?}", bytes);

Deserialize

To deserialize data back into an object you should use serde_rlp::de::from_bytes.

extern crate serde_rlp;
use serde_rlp::de::from_bytes;

// Deserialize string "abc" encoded as RLP
let foo: String = from_bytes(&[0x83, 0x61, 0x62, 0x63]).unwrap();
println!("{}", foo);

An useful pattern is to deserialize into Vec<Bytes>, which will correctly deserialize elements of a RLP list.

serde-rlp's People

Contributors

mpapierski avatar aaronkutch avatar

Stargazers

ownerlesswhisper avatar

Watchers

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