#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 2472/week @ 2019-11-01 2108/week @ 2019-11-08 1672/week @ 2019-11-15 1783/week @ 2019-11-22 1769/week @ 2019-11-29 2299/week @ 2019-12-06 1053/week @ 2019-12-13 410/week @ 2019-12-20 558/week @ 2019-12-27 488/week @ 2020-01-03 580/week @ 2020-01-10 675/week @ 2020-01-17 627/week @ 2020-01-24 749/week @ 2020-01-31 757/week @ 2020-02-07

7,420 downloads per month
Used in 20 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

~0.6–1MB
~22K SLoC