alef 0.23.35

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  def {{ method_name }}(%__MODULE__{} = {{ params }}) do
    # Wrap handler closure in a process if it's not already one
    handler_pid =
      case handler do
        pid when is_pid(pid) ->
          pid

        fun when is_function(fun) ->
          {:ok, pid} = GenServer.start_link(__MODULE__.HandlerWrapper, fun)
          pid
      end

    entry = {"{{ method_name }}", {{ meta_tuple }}, handler_pid}
    %__MODULE__{self | registrations: [entry | self.registrations]}
  end