@@ -317,10 +317,59 @@ defmodule Msgpack do
317317 end
318318 end
319319
320+ @ doc """
321+ Encodes a stream of Elixir terms into a stream of MessagePack binaries.
322+
323+ Each term in the input enumerable is encoded individually. The output stream
324+ will contain `{:ok, binary}` tuples for successful encodings or `{:error,
325+ reason}` tuples for failures.
326+
327+ This function delegates to `Msgpack.StreamEncoder.encode/2`.
328+
329+ ## Options
330+
331+ Accepts the same options as `Msgpack.encode/2`.
332+
333+ ## Examples
334+
335+ ```elixir
336+ iex> terms = [1, "elixir", :world]
337+ iex> Msgpack.encode_stream(terms, atoms: :string) |> Enum.to_list()
338+ [
339+ {:ok, <<1>>},
340+ {:ok, <<166, 101, 108, 105, 120, 105, 114>>},
341+ {:ok, <<165, 119, 111, 114, 108, 100>>}
342+ ]
343+ ```
344+ """
320345 def encode_stream ( enumerable , opts \\ [ ] ) do
321346 StreamEncoder . encode ( enumerable , opts )
322347 end
323348
349+ @ doc """
350+ Decodes a stream of MessagePack binaries into a stream of Elixir terms.
351+
352+ This function provides a streaming, lazy interface for decoding, making it
353+ suitable for handling large datasets that do not fit into memory.
354+
355+ It delegates to `Msgpack.StreamDecoder.decode/2`.
356+
357+ For more detailed information on behavior, see the `Msgpack.StreamDecoder`
358+ module documentation.
359+
360+ ## Options
361+
362+ Accepts the same options as `Msgpack.decode/2`.
363+
364+ ## Examples
365+
366+ ```elixir
367+ iex> objects = [1, "elixir", true]
368+ iex> stream = Enum.map(objects, &Msgpack.encode!/1)
369+ iex> Msgpack.decode_stream(stream) |> Enum.to_list()
370+ [1, "elixir", true]
371+ ```
372+ """
324373 def decode_stream ( enumerable , opts \\ [ ] ) do
325374 StreamDecoder . decode ( enumerable , opts )
326375 end
0 commit comments