#thrift

thrift_codec

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

2 releases

Uses old Rust 2015

0.1.1 Oct 19, 2017
0.1.0 Oct 12, 2017

#248 in Web programming

Download history 479/week @ 2020-05-27 606/week @ 2020-06-03 475/week @ 2020-06-10 481/week @ 2020-06-17 364/week @ 2020-06-24 625/week @ 2020-07-01 1100/week @ 2020-07-08 935/week @ 2020-07-15 724/week @ 2020-07-22 689/week @ 2020-07-29 852/week @ 2020-08-05 972/week @ 2020-08-12 1007/week @ 2020-08-19 1186/week @ 2020-08-26 1011/week @ 2020-09-02 1303/week @ 2020-09-09

2,559 downloads per month
Used in 22 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.5–1MB
~25K SLoC