Initial commit of alternative erlang lib


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666374 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/alterl/src/thrift_transport.erl b/lib/alterl/src/thrift_transport.erl
new file mode 100644
index 0000000..bf9dc53
--- /dev/null
+++ b/lib/alterl/src/thrift_transport.erl
@@ -0,0 +1,29 @@
+-module(thrift_transport).
+
+-export([behaviour_info/1,
+
+         new/2,
+         write/2,
+         read/2
+        ]).
+
+behaviour_info(callbacks) ->
+    [{write/2,
+      read/2}];
+behaviour_info(_Else) -> undefined.
+
+
+-record(transport, { module, data }).
+
+
+new(Module, Data) when is_atom(Module) ->
+    {ok, #transport{module = Module,
+                    data = Data}}.
+
+write(Transport, Data) when is_binary(Data) ->
+    Module = Transport#transport.module,
+    Module:write(Transport#transport.data, Data).
+
+read(Transport, Len) when is_integer(Len) ->
+    Module = Transport#transport.module,
+    Module:read(Transport#transport.data, Len).