#thrift

thrift_codec

A library for encoding/decoding binaries specified by the thrift protocol

2 releases

0.1.1 Oct 19, 2017
0.1.0 Oct 12, 2017

#2 in #thrift

Download history 148/week @ 2019-07-01 176/week @ 2019-07-15 258/week @ 2019-07-22 272/week @ 2019-07-29 447/week @ 2019-08-05 149/week @ 2019-08-12 315/week @ 2019-08-19 386/week @ 2019-08-26 295/week @ 2019-09-02 556/week @ 2019-09-09 1565/week @ 2019-09-16 837/week @ 2019-09-23 1527/week @ 2019-09-30 1931/week @ 2019-10-07

1,099 downloads per month
Used in 17 crates (2 directly)

MIT license

68KB
1.5K SLoC

thrift_codec

Crates.io: thrift_codec Documentation Build Status Code Coverage License: MIT

This crate provides functionalities for encoding/deconding Thrift protocol.

Documentation

References

Examples

Encodes a message:

use thrift_codec::CompactEncode;
use thrift_codec::data::Struct;
use thrift_codec::message::Message;

let message = Message::oneway("foo_method", 1, Struct::from(("arg1", 2)));
let mut buf = Vec::new();
message.compact_encode(&mut buf).unwrap();
assert_eq!(
    buf,
    [130, 129, 1, 10, 102, 111, 111, 95, 109, 101, 116,
    104, 111, 100, 24, 4, 97, 114, 103, 49, 21, 4, 0]
);

Decodes the above binary:

use thrift_codec::CompactDecode;
use thrift_codec::data::Struct;
use thrift_codec::message::Message;

let bytes = [
    130, 129, 1, 10, 102, 111, 111, 95, 109, 101, 116,
    104, 111, 100, 24, 4, 97, 114, 103, 49, 21, 4, 0
];

let message = Message::compact_decode(&mut &bytes[..]).unwrap();
let expected = Message::oneway("foo_method", 1, Struct::from(("arg1", 2)));
assert_eq!(message, expected);

Dependencies

~1.5MB
~29K SLoC