the value type of the data type
the type(s) from which a value can be constructed
the binary type containing the CBOR data
Test whether this data type is compatible with valueType
. Compatibility
with a valueType
means than any valid binary representation of a
value
can be read as an
instance of valueType
.
Every data type should be compatible with the following:
Value Type
– the class corresponding to the data type's value
type.For a data type with a value type of X
, readAs(X, buffer)
is
equivalent to readValue(buffer)
.
the type to check
true
if a binary representation created by this data
type can read as an instance * of valueType
Obtain a DeltaType by name or delta type.
Example:
// Get by name
var deltas = datatype.deltaType("binary");
Example:
// Get by type
var deltas = datatype.deltaType(delta);
the name, as returned by DeltaType.name
the delta type
The external type identifier.
the name of this datatype
Create a value of a compatible class from binary.
the type of the result
the binary data
the offset to start reading from the provided buffer (default = 0
)
the length of the data to read (default = input.length
)
the value in the form of the specified type
Parse a value from binary.
When running the Diffusion Client in a browser context, access to the
Buffer
api is made available through diffusion.buffer.
the binary data
the offset to start reading from the provided buffer (default = 0
)
the length of the data to read (default = input.length
)
an instance of this data type value
Serialise a value to binary
When running the Diffusion Client in a browser context, access to the
Buffer
api is made available through diffusion.buffer.
the value to serialise. For primitive and JSON datatypes
the value can be undefined
or null
. In this case a
null
value will be serialised.
the serialised value as a buffer
A data type is specified for a particular value type. It provides methods to convert values to and from binary. Diffusion provides several DataType implementations.
A data type can optionally support incremental changes to values, represented by one or more types of delta. A delta is the difference between two values. For large or composite values that change in small steps, it is more efficient to transmit an initial value followed by a delta for each change than to transmit a complete value for each change. The data type provides an implementation of DeltaType for each type of delta it supports via DataType.deltaType.
5.7