  @doc "Streaming `{{ core_path }}` — returns an `Enumerable` of decoded chunk maps."
  def {{ stream_fn }}(client, {{ req_param }}) do
    req_json =
      case {{ req_param }} do
        nil -> nil
        s when is_binary(s) -> s
        other -> Jason.encode!(other)
      end

    case {{ native_mod }}.{{ start_fn }}(client, req_json) do
      {:ok, handle} ->
        stream =
          Stream.unfold(handle, fn h ->
            case {{ native_mod }}.{{ next_fn }}(h) do
              {:ok, nil} ->
                nil

              {:ok, chunk_json} ->
                {Jason.decode!(chunk_json, keys: :atoms), h}

              {:error, reason} ->
                raise {{ exception_module }},
                  message: "{{ stream_fn }} stream failed: #{inspect(reason)}",
                  reason: reason,
                  adapter: :{{ stream_fn }}
            end
          end)

        {:ok, stream}

      {:error, reason} ->
        {:error, reason}
    end
  end
