blob: bf9dc53b9639540098f9aaa55cfbb179f8841cad [file] [log] [blame]
David Reissac549552008-06-10 22:56:59 +00001-module(thrift_transport).
2
3-export([behaviour_info/1,
4
5 new/2,
6 write/2,
7 read/2
8 ]).
9
10behaviour_info(callbacks) ->
11 [{write/2,
12 read/2}];
13behaviour_info(_Else) -> undefined.
14
15
16-record(transport, { module, data }).
17
18
19new(Module, Data) when is_atom(Module) ->
20 {ok, #transport{module = Module,
21 data = Data}}.
22
23write(Transport, Data) when is_binary(Data) ->
24 Module = Transport#transport.module,
25 Module:write(Transport#transport.data, Data).
26
27read(Transport, Len) when is_integer(Len) ->
28 Module = Transport#transport.module,
29 Module:read(Transport#transport.data, Len).