Snodo.Envelope (snodo v0.1.0)

Copy Markdown View Source

A decoded JSON-RPC message before dialect-specific resolution.

Summary

Functions

Decodes the protocol-neutral JSON-RPC envelope without choosing a dialect.

Whether a decoded JSON value identifies itself as a notification: a string method and no id. JSON-RPC forbids replying to one, even when it is otherwise malformed.

Whether a decoded JSON value is a JSON-RPC response object: no method, and a result or error member. A server has nothing to answer to one.

Types

id()

@type id() :: String.t() | integer() | nil

t()

@type t() :: %Snodo.Envelope{
  id: id(),
  kind: :request | :notification,
  method: String.t(),
  params: map(),
  raw: map(),
  transport: Snodo.Transport.Context.t()
}

Functions

decode(raw, transport)

@spec decode(term(), Snodo.Transport.Context.t()) ::
  {:ok, t()} | {:error, Snodo.Error.t()}

Decodes the protocol-neutral JSON-RPC envelope without choosing a dialect.

notification?(raw)

@spec notification?(term()) :: boolean()

Whether a decoded JSON value identifies itself as a notification: a string method and no id. JSON-RPC forbids replying to one, even when it is otherwise malformed.

response?(raw)

@spec response?(term()) :: boolean()

Whether a decoded JSON value is a JSON-RPC response object: no method, and a result or error member. A server has nothing to answer to one.