erlang: Refactor the binary protocol

At this point, everything passes dialyzer except for the processor,
and the client works.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@990983 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/include/thrift_protocol_impl.hrl b/lib/erl/include/thrift_protocol_impl.hrl
index ae0f0f7..de6bb7b 100644
--- a/lib/erl/include/thrift_protocol_impl.hrl
+++ b/lib/erl/include/thrift_protocol_impl.hrl
@@ -22,16 +22,16 @@
 -ifndef(THRIFT_PROTOCOL_IMPL_INCLUDED).
 -define(THRIFT_PROTOCOL_IMPL_INCLUDED, true).
 
--spec flush_transport(state()) -> ok.
--spec close_transport(state()) -> ok.
+-spec flush_transport(state()) -> {state(), ok | {error, _Reason}}.
+-spec close_transport(state()) -> {state(), ok | {error, _Reason}}.
 
--spec write(state(), term()) -> ok | {error, _Reason}.
+-spec write(state(), term()) -> {state(), ok | {error, _Reason}}.
 
 %% NOTE: Keep this in sync with thrift_protocol:read and read_specific.
 -spec read
-        (state(), tprot_empty_tag()) ->   ok                | {error, _Reason};
-        (state(), tprot_header_tag()) -> tprot_header_val() | {error, _Reason};
-        (state(), tprot_data_tag()) ->   {ok, term()}       | {error, _Reason}.
+        (state(), tprot_empty_tag()) ->  {state(),  ok                | {error, _Reason}};
+        (state(), tprot_header_tag()) -> {state(), tprot_header_val() | {error, _Reason}};
+        (state(), tprot_data_tag()) ->   {state(), {ok, term()}       | {error, _Reason}}.
 
 
 -endif.