#codec #compact #data-structures #data-structure #thrift-codec

thrift_codec

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

3 unstable releases

0.2.0 Apr 6, 2022
0.1.1 Oct 19, 2017
0.1.0 Oct 12, 2017

#730 in Encoding

Download history 10884/week @ 2023-06-05 6456/week @ 2023-06-12 6397/week @ 2023-06-19 4094/week @ 2023-06-26 4342/week @ 2023-07-03 3839/week @ 2023-07-10 3709/week @ 2023-07-17 4065/week @ 2023-07-24 10268/week @ 2023-07-31 9874/week @ 2023-08-07 8060/week @ 2023-08-14 12422/week @ 2023-08-21 8956/week @ 2023-08-28 6482/week @ 2023-09-04 13508/week @ 2023-09-11 9404/week @ 2023-09-18

39,037 downloads per month
Used in 25 crates (3 directly)

MIT license

69KB
1.5K SLoC

thrift_codec

thrift_codec Documentation Actions Status Coverage Status 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–1.5MB
~35K SLoC