Crate thrift_codec [] [src]

This crate provides functionalities for encoding/deconding Thrift protocol.

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);

Modules

data

Data types.

message

RPC message.

Structs

Error

This crate specific error type.

Enums

ErrorKind

The list of the possible error kinds

Traits

BinaryDecode

This trait allows to decode objects which encoded by the Thrift Binary protocol encoding.

BinaryEncode

This trait allows to encode objects to the binaries specified by the Thrift Binary protocol encoding.

CompactDecode

This trait allows to decode objects which encoded by the Thrift Compact protocol encoding.

CompactEncode

This trait allows to encode objects to the binaries specified by the Thrift Compact protocol encoding.

Type Definitions

Result

This crate specific Result type.