alef 0.25.37

Opinionated polyglot binding generator for Rust libraries
Documentation
{% if doc_first %}
  @doc "{{ doc_first }}"
{% endif %}  def {{ method_name }}({{ def_args }}) do
    case Native.{{ start_fn }}({{ start_call_args }}) do
      {:ok, handle} ->
        stream =
          Stream.unfold(handle, fn h ->
            case Native.{{ next_fn }}(h) do
              {:ok, nil} ->
                nil

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

              {:ok, chunk} ->
                {chunk, h}

              {:error, _} ->
                nil
            end
          end)

        {:ok, stream}

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