Optional extension provided by DataType implementations that support incremental changes to values.
Each implementation specifies a
value type and a
Two values, oldValue and new Value, can be compared to produce a delta using
DeltaType.diff. The delta can be separately applied to oldValue to
create newValue using DeltaType.apply.
the value type of the data type
the type(s) from which a value can be constructed
the binary type containing the CBOR data
Apply a delta to a value.
the delta to apply
the new value generated applying the delta to the old value
Create a delta from two values.
If there are many differences between oldValue and newValue, the result might require more bytes to transmit than the new value, or be computationally expensive to apply. In this case, it is better to discard oldValue and publish newValue in its place. This can be checked using DeltaType.isValueCheaper.
The implementation can return the special constant DeltaType.noChange to indicate the old value and new value are equivalent and there is no change to publish.
the old value
the new value
the delta between values
value is cheaper than the
result is typically determined by the length of the serialised form, but may
also consider the complexity of the delta.
the value to compare
the delta to compare
true if the value is considered cheaper than the delta
The name of this delta type
Parse a delta from binary.
the offset from which to start reading from the buffer
the length of data to read from the buffer
Serialise a delta to binary.
the delta to serialise
the serialised form of the delta