Pure decoder for the field payload of a U notification.
Updates are deltas against the previous per-item field state: the payload is
a pipe-separated token list where an empty token means unchanged, #
means null, $ means empty string, ^n skips n unchanged fields at once,
and anything else is percent-encoded content (#, $ and ^ arrive
escaped when literal at position 0). ^P/^T diff tokens are rejected
explicitly — this library disables them via LS_supported_diffs= at session
creation, so seeing one is an error, never a silently wrong value.
Summary
Functions
Applies one raw U field payload to the previous field values.
Functions
@spec apply(binary(), [String.t() | nil]) :: {:ok, [String.t() | nil], [pos_integer()]} | {:error, {:unsupported_diff, binary()}}
Applies one raw U field payload to the previous field values.
previous_values is the positional per-item state (use all-nil before the
first update — a snapshot carries every field). Returns the merged values
plus the ascending 1-based indexes of the fields this payload transmitted.
Payloads that do not cover the schema exactly violate a protocol invariant
and raise ArgumentError — the session process is expected to crash.
Examples
iex> Lightstreamer.Protocol.Update.apply("21:14:00|3.05|^2|$", [nil, nil, "2.41", "3.67", "old"])
{:ok, ["21:14:00", "3.05", "2.41", "3.67", ""], [1, 2, 5]}
iex> Lightstreamer.Protocol.Update.apply("^Pnot-json-patch", [nil])
{:error, {:unsupported_diff, "P"}}