From ee93398ccc61843239c24aabeafc8d4d7a6ec27e Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 30 Aug 2010 22:05:22 +0000 Subject: [PATCH] erlang: Add some more detailed specs for protocol implementations git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@990974 13f79535-47bb-0310-9956-ffa450edef68 --- lib/erl/include/thrift_protocol.hrl | 31 ++++++++++++++++++++++++ lib/erl/include/thrift_protocol_impl.hrl | 8 +++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/erl/include/thrift_protocol.hrl b/lib/erl/include/thrift_protocol.hrl index fa95acf4..201badea 100644 --- a/lib/erl/include/thrift_protocol.hrl +++ b/lib/erl/include/thrift_protocol.hrl @@ -27,5 +27,36 @@ -record(protocol_list_begin, {etype, size}). -record(protocol_set_begin, {etype, size}). +-type tprot_header_val() :: #protocol_message_begin{} + | #protocol_struct_begin{} + | #protocol_field_begin{} + | #protocol_map_begin{} + | #protocol_list_begin{} + | #protocol_set_begin{} + . +-type tprot_empty_tag() :: message_end + | struct_begin + | struct_end + | field_end + | map_end + | list_end + | set_end + . +-type tprot_header_tag() :: message_begin + | field_begin + | map_begin + | list_begin + | set_begin + . +-type tprot_data_tag() :: ui32 + | bool + | byte + | i16 + | i32 + | i64 + | double + | string + . + -endif. diff --git a/lib/erl/include/thrift_protocol_impl.hrl b/lib/erl/include/thrift_protocol_impl.hrl index 7d8abae0..e816d790 100644 --- a/lib/erl/include/thrift_protocol_impl.hrl +++ b/lib/erl/include/thrift_protocol_impl.hrl @@ -24,8 +24,14 @@ -spec flush_transport(state()) -> ok. -spec close_transport(state()) -> ok. + -spec write(state(), term()) -> ok | {error, _Reason}. --spec read(state(), term()) -> term(). + +-spec read + (state(), non_neg_integer()) -> {ok, binary()} | {error, _Reason}; + (state(), tprot_empty_tag()) -> ok | {error, _Reason}; + (state(), tprot_header_tag()) -> tprot_header_val() | {error, _Reason}; + (state(), tprot_data_tag()) -> {ok, term()} | {error, _Reason}. -endif. -- 2.17.1