Module thrift_protocol

An Erlang implementation of Thrift protocol.

Description

An Erlang implementation of Thrift protocol.

Examples

  Body =
      #thrift_protocol_struct{
          fields = #{1 => true, 2 => {i8, -1}}
      },
  Message =
      #thrift_protocol_message{
          method_name = <<"foo">>,
          message_type = call,
          sequence_id = 0,
          body = Body
      },
 
  Encoded = list_to_binary(thrift_protocol:encode_message(Message, compact)),
  <<130,33,0,3,102,111,111,17,19,255,0>> = Encoded,
 
  {Decoded, <<>>} = thrift_protocol:decode_message(Encoded, compact),
  Message = Decoded.

References

Data Types

data()

data() = boolean() | i8() | i16() | i32() | i64() | float() | binary() | struct() | thrift_map() | set() | thrift_list()

Data.

data_type()

data_type() = boolean | i8 | i16 | i32 | i64 | float | binary | struct | map | set | list

Data type.

field_id()

field_id() = integer()

The identifier of a struct field (16-bit signed integer).

format()

format() = binary | compact

Protocol encoding format.

i16()

i16() = {i16, integer()}

16-bit signed integer.

i32()

i32() = {i32, integer()}

32-bit signed integer.

i64()

i64() = {i64, integer()}

64-bit signed integer.

i8()

i8() = {i8, integer()}

8-bit signed integer.

message()

message() = #thrift_protocol_message{method_name = binary(), message_type = thrift_protocol:message_type(), sequence_id = integer(), body = thrift_protocol:struct()}

Message.

message_type()

message_type() = call | reply | exception | oneway

Message type.

set()

set() = #thrift_protocol_set{element_type = thrift_protocol:data_type(), elements = [thrift_protocol:data()]}

Set.

struct()

struct() = #thrift_protocol_struct{fields = #{}}

Struct.

thrift_list()

thrift_list() = #thrift_protocol_list{element_type = thrift_protocol:data_type(), elements = [thrift_protocol:data()]}

List.

thrift_map()

thrift_map() = #thrift_protocol_map{key_type = thrift_protocol:data_type() | undefined, value_type = thrift_protocol:data_type() | undefined, elements = #{}}

Map.

Function Index

data_type/1Returns the type of Data.
decode_message/2Decodes a message from the given binary.
decode_struct/2Decodes a struct from the given binary.
encode_message/2Encodes Message.
encode_struct/2Encodes Struct.

Function Details

data_type/1

data_type(Data::data()) -> data_type()

Returns the type of Data.

decode_message/2

decode_message(Bin::binary(), Format::format()) -> {message(), binary()}

Decodes a message from the given binary.

decode_struct/2

decode_struct(Bin::binary(), Format::format()) -> {struct(), binary()}

Decodes a struct from the given binary.

encode_message/2

encode_message(Message::message(), Format::format()) -> iodata()

Encodes Message.

encode_struct/2

encode_struct(Struct::struct(), Format::format()) -> iodata()

Encodes Struct.


Generated by EDoc, Jan 18 2020, 13:40:49.