@@ -23,6 +23,12 @@ defmodule Msgpack.StreamDecoder do
2323 alias Msgpack.Decoder
2424 alias Msgpack.Decoder.Internal
2525
26+ @ typedoc "A stream that yields decoded Elixir terms."
27+ @ type t :: Stream . t ( )
28+
29+ @ typedoc "Options passed to the decoder."
30+ @ type opts_t :: keyword ( )
31+
2632 @ doc """
2733 Lazily decodes an enumerable of MessagePack binaries into a stream of Elixir
2834 terms.
@@ -70,6 +76,7 @@ defmodule Msgpack.StreamDecoder do
7076 [{:error, :unexpected_eof}]
7177 ```
7278 """
79+ @ spec decode ( Enumerable . t ( binary ( ) ) , opts_t ( ) ) :: t ( )
7380 def decode ( enumerable , opts \\ [ ] ) do
7481 start_fun = fn ->
7582 merged_opts = Keyword . merge ( Decoder . default_opts ( ) , opts )
@@ -82,6 +89,8 @@ defmodule Msgpack.StreamDecoder do
8289 Stream . transform ( stream_with_eof , start_fun . ( ) , transform_fun )
8390 end
8491
92+ @ doc false
93+ @ spec transform_chunk ( binary ( ) | :eof , { binary ( ) , opts_t ( ) } ) :: { list ( ) , { binary ( ) , opts_t ( ) | nil } }
8594 defp transform_chunk ( :eof , { << >> , _opts } ) do
8695 { [ ] , { << >> , nil } }
8796 end
@@ -95,6 +104,8 @@ defmodule Msgpack.StreamDecoder do
95104 { decoded_terms , { leftover_buffer , opts } }
96105 end
97106
107+ @ doc false
108+ @ spec do_transform ( binary ( ) , opts_t ( ) , list ( ) ) :: { list ( ) , binary ( ) }
98109 defp do_transform ( << >> , _opts , acc ) do
99110 { Enum . reverse ( acc ) , << >> }
100111 end
0 commit comments