diff --git a/lib/grpc/client/adapter.ex b/lib/grpc/client/adapter.ex index 5160d55f6..427bf5e52 100644 --- a/lib/grpc/client/adapter.ex +++ b/lib/grpc/client/adapter.ex @@ -14,7 +14,7 @@ defmodule GRPC.Client.Adapter do @callback disconnect(channel :: Channel.t()) :: {:ok, Channel.t()} | {:error, any()} - @callback send_request(stream :: Stream.t(), contents :: binary(), opts :: keyword()) :: + @callback send_request(stream :: Stream.t(), contents :: iodata(), opts :: keyword()) :: Stream.t() @doc """ @@ -36,7 +36,7 @@ defmodule GRPC.Client.Adapter do Opts: - :send_end_stream (optional) - ends the request stream """ - @callback send_data(stream :: Stream.t(), message :: binary(), opts :: keyword()) :: Stream.t() + @callback send_data(stream :: Stream.t(), message :: iodata(), opts :: keyword()) :: Stream.t() @doc """ Similarly to the option sent on `send_data/2` - :send_end_stream - diff --git a/lib/grpc/codec.ex b/lib/grpc/codec.ex index b7a15ab82..e052a95eb 100644 --- a/lib/grpc/codec.ex +++ b/lib/grpc/codec.ex @@ -5,7 +5,7 @@ defmodule GRPC.Codec do @doc ~s(Name is identity of the codec, which will be suffix after content-type "application/grpc+" such as "proto".) @callback name() :: String.t() - @callback encode(any) :: binary + @callback encode(any) :: iodata() @callback decode(any, module :: atom) :: any @doc """ diff --git a/lib/grpc/codec/proto.ex b/lib/grpc/codec/proto.ex index d3de8b166..db89922ff 100644 --- a/lib/grpc/codec/proto.ex +++ b/lib/grpc/codec/proto.ex @@ -5,8 +5,8 @@ defmodule GRPC.Codec.Proto do "proto" end - def encode(%mod{} = struct) do - mod.encode(struct) + def encode(struct) do + Protobuf.Encoder.encode_to_iodata(struct) end def decode(binary, module) do diff --git a/lib/grpc/compressor.ex b/lib/grpc/compressor.ex index ca0b2439a..37abc2e4e 100644 --- a/lib/grpc/compressor.ex +++ b/lib/grpc/compressor.ex @@ -1,5 +1,5 @@ defmodule GRPC.Compressor do @callback name() :: String.t() - @callback compress(binary) :: binary + @callback compress(iodata()) :: binary @callback decompress(binary) :: binary end