#thrift #binary-encoding #codec #protocols #binary-data #data-encoding #message

thrift_codec

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

6 releases

0.3.2 Jun 11, 2024
0.3.1 Jan 16, 2024
0.2.0 Apr 6, 2022
0.1.1 Oct 19, 2017

#377 in Encoding

Download history 12422/week @ 2024-06-27 11972/week @ 2024-07-04 13522/week @ 2024-07-11 14223/week @ 2024-07-18 15177/week @ 2024-07-25 16056/week @ 2024-08-01 14534/week @ 2024-08-08 13276/week @ 2024-08-15 12895/week @ 2024-08-22 13826/week @ 2024-08-29 15138/week @ 2024-09-05 15211/week @ 2024-09-12 19910/week @ 2024-09-19 23443/week @ 2024-09-26 20479/week @ 2024-10-03 20324/week @ 2024-10-10

86,743 downloads per month
Used in 45 crates (5 directly)

MIT license

72KB
1.5K SLoC

thrift_codec

thrift_codec Documentation Actions Status License: MIT

This crate provides functionalities for encoding/decoding 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
~39K SLoC