Sha256: 1ac5cd2f4c2c21f9ac08bd191041d886dab9c89f038eeff9caa2a75e2cbbba35

Contents?: true

Size: 1.09 KB

Versions: 28

Compression:

Stored size: 1.09 KB

Contents

-module(thrift_base64_transport).

-behaviour(thrift_transport).

%% API
-export([new/1, new_transport_factory/1]).

%% thrift_transport callbacks
-export([write/2, read/2, flush/1, close/1]).

%% State
-record(b64_transport, {wrapped}).

new(Wrapped) ->
    State = #b64_transport{wrapped = Wrapped},
    thrift_transport:new(?MODULE, State).


write(#b64_transport{wrapped = Wrapped}, Data) ->
    thrift_transport:write(Wrapped, base64:encode(iolist_to_binary(Data))).


%% base64 doesn't support reading quite yet since it would involve
%% nasty buffering and such
read(#b64_transport{wrapped = Wrapped}, Data) ->
    {error, no_reads_allowed}.


flush(#b64_transport{wrapped = Wrapped}) ->
    thrift_transport:write(Wrapped, <<"\n">>),
    thrift_transport:flush(Wrapped).


close(Me = #b64_transport{wrapped = Wrapped}) ->
    flush(Me),
    thrift_transport:close(Wrapped).


%%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
new_transport_factory(WrapFactory) ->
    F = fun() ->
                {ok, Wrapped} = WrapFactory(),
                new(Wrapped)
        end,
    {ok, F}.

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.1 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.10 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.11 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.12 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.13 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.14 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.15 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.16 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.17 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.2 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.3 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.4 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.5 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.6 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.7 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
auser-poolparty-1.3.8 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
fairchild-poolparty-1.3.17 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
fairchild-poolparty-1.3.5 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl
poolparty-1.3.15 examples/thrift/erlang/deps/thrift/src/thrift_base64_transport.erl