Behaviour for ONC RPC program handlers.
A handler is a module that implements handle_call/4 and is
registered with Tahr.RPC.Dispatcher for one or more
{program, version} pairs. The dispatcher peels the RPC envelope,
validates the credential flavor, and invokes:
handle_call(proc, args_binary, auth_context, ctx)The handler decodes args_binary (typically with Tahr.XDR
helpers), produces a result, and returns one of the result tuples
below. The dispatcher wraps the result in the RPC reply envelope.
Return values
{:ok, encoded_body}— successful reply,encoded_bodyis the already-XDR-encoded result body. May be a binary or iodata — streaming-aware procedures (NFSv3 READ) return chunked iodata so a multi-MiB read body never has to be flattened in memory. The dispatcher andRPC.RecordMarkingpropagate iodata through to:gen_tcp.send/2.:proc_unavail— the procedure number isn't implemented; the dispatcher returnsPROC_UNAVAIL.:garbage_args—args_binarycouldn't be decoded; the dispatcher returnsGARBAGE_ARGS.:system_err— handler crashed or a downstream system error; the dispatcher returnsSYSTEM_ERR.
The ctx argument is a map carrying the original call envelope as
:call (Tahr.RPC.Message.Call.t()) and the connection's client
address as :peer (an :inet.ip_address(), or nil if unavailable) —
the latter for per-export host filtering. Further fields (e.g.
TLS info) can be added without breaking handlers.
Summary
Types
@type ctx() :: %{call: Tahr.RPC.Message.Call.t()}
@type result() :: {:ok, body :: iodata()} | :proc_unavail | :garbage_args | :system_err
The reply body — handler-encoded XDR or a structured error.
Callbacks
@callback handle_call( proc :: non_neg_integer(), args :: binary(), auth :: Tahr.RPC.Auth.credential(), ctx() ) :: result()