#thrift #codec #protocols #message #binary #binaries

thrift_codec

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

5 unstable releases

0.3.1 Jan 16, 2024
0.3.0 Jan 13, 2024
0.2.0 Apr 6, 2022
0.1.1 Oct 19, 2017
0.1.0 Oct 12, 2017

#463 in Encoding

Download history 6837/week @ 2024-01-22 6651/week @ 2024-01-29 6659/week @ 2024-02-05 7949/week @ 2024-02-12 6064/week @ 2024-02-19 7834/week @ 2024-02-26 9412/week @ 2024-03-04 9234/week @ 2024-03-11 10407/week @ 2024-03-18 8336/week @ 2024-03-25 9252/week @ 2024-04-01 9306/week @ 2024-04-08 9003/week @ 2024-04-15 10678/week @ 2024-04-22 11625/week @ 2024-04-29 10111/week @ 2024-05-06

41,855 downloads per month
Used in 36 crates (4 directly)

MIT license

67KB
1.5K SLoC

thrift_codec

thrift_codec Documentation Actions 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.5MB
~38K SLoC