binary_data library

Bits and byte structures, and binary format/codec for encoding/decoding to/from binary data.

Classes

Accum16
Adcu
Marker for special handling, closing the sealed hierarchy.
Angle16
0, 65536 -> [0.0, 1)
Angle16Deg
0, 65536 -> [0.0, 360.0)
Angle16Rad
0, 65536 -> [0.0, 2π)
BinaryCodec<V>
BinaryCodec<V>
BinaryCodecByHandlers<V>
BinaryCodecIdentity
BinaryFormat<S extends NativeType, V>
BinaryFormat<S, V> defines value handling type V to and from a binary representation as an int, It provides a declarative way to handle various data formats, including integers, fixed-point numbers, booleans, signs, and enums, with support for custom encoding/decoding logic through handlers. V determines value conversion
BinaryQuantityCodec<V extends num>
Quantity Codec
BitData
BitData contain bits for setters - Cannot be extension type allows pass by pointer use by BitsMap. BitsStuct, BoolMap, etc.
BitField
BitField Key for BitStruct and BitFieldMap as mixin, applicable to enum
BitFieldMap<K extends BitField>
BitFieldMap
BitIndexField
BitIndexField /// Special case: single-bit field addressed by index.
Bitmask
Bitmask
BitsInitializer<K extends BitField>
BitsInitializer compile time const definition using map literal example = BitsInitializer({ EnumType.name1: 2, EnumType.name2: 3, });
BitsMap<K, V>
BitsMap Common interface for [BitFieldMap, BoolMap. Enforce concrete keys as base. A special case of FixedMap, all values retrieve from a Bits object Map operators implemented by subclass depending on V type, int or bool.
BitStructBase<T extends BitStructBase<T, K>, K extends BitField>
BitStructBase — abstract base for user-defined bit struct subtypes. Analogue of StructBase for the bit domain.
BitStructFormat<K extends BitField>
Bool
Represents a native bool in C.
BoolFormat
BoolMap<K extends dynamic>
BoolMap
ByteField<V extends NativeType>
ByteField - a Typed Offset into a ByteStruct and TypedData. Defines a field of a ByteStruct by its offset and type.
ByteStructBase<S extends ByteStructBase<S, K>, K extends ByteField<NativeType>>
ByteStructBase — abstract base for user-defined byte struct subtypes.
ByteStructBuffer<T>
buffer type for partial view
ConstBitFieldMap<K extends BitField>
ConstBits
ConstBoolMap<K extends dynamic>
Decimal10<S extends NativeType>
1 binary -> 0.1f
Decimal100<S extends NativeType>
DecimalInv10<S extends NativeType>
1 binary -> 10.0f
Double
Represents a native 64 bit double in C.
EnumFormat<S extends NativeType, V extends Enum>
EnumFormatByHandlers<V extends Enum>
for custom handling, separate from index-based. include list for view
EnumOffsetFormat<S extends NativeType, V extends Enum>
Field<V>
Field — key to a value in a host struct, carrying accessor logic and type scope
FixedMap<K, V>
FixedMap - interface for Map constraints FixedMap - fixed set of keys optimized for small fixed set of keys guarantees all keys are present can guarantee non null return - if V is defined as non nullable
FixedPoint<S extends NativeType>
FixedPointBase10<S extends NativeType>
FixedPointN<S extends NativeType>
Float
Represents a native 32 bit float in C.
Fract16
FractFormat<S extends NativeType>
IndexMap<K extends dynamic, V>
IndexMap Default implementation using parallel arrays
Int
The C int type.
Int16
Represents a native signed 16 bit integer in C.
Int16Int
Int32
Represents a native signed 32 bit integer in C.
Int32Int
Int64
Represents a native signed 64 bit integer in C.
Int8
Represents a native signed 8 bit integer in C.
Int8Int
IntFormat<S extends NativeType>
MutableBitFieldMap<K extends BitField>
MutableBits
base for Map or Struct
MutableBoolMap<K extends dynamic>
NativeType
NativeType's subtypes represent a native type in C.
NativeTypeBase<S extends NativeType>
NativeTag - StorageType. Descriptor using NativeType as marker only. NativeType S determines the size and signedness of the underlying binary data. if lets unspecified, defaults to 32-bit signed int (Int32).
NumFormat<S extends NativeType, V extends num>
Hierarchy axis on handling, rather than storage Base sttorage type can be "inherited" by typedef with type marker Int/Fract
Packet
Packet as interface for immutable view of varying view length.
PacketBuffer<T extends Packet>
/////////////////////////////////////////////////////////////////////////
PacketFormat<T extends Packet>
Collective def of Packet format. Descriptor/'Class variables'
PacketId
PacketIdCaster
///////////////////////////////////////////////////////////////////////// PacketId Types ///////////////////////////////////////////////////////////////////////// build idOf from lists internally PacketIdFactory
PacketIdRequest<T, R>
Id as payload factory A Request matched with a Response paired request response id for simplicity in case of shared id by request and response can under define responseId for 1-way handlers as constructors, const for enum
PacketPayloadId<V>
PacketSyncId
Payload<V>
Payload<V>
PayloadMeta
any additional state not included in the header
Percent16
SerializableField<V>
SerializableField<V>/NamedField a key to each field, an type parameter, with an generated string, use as json key; effectively describe the memory allocation requirements maps entirety of the struct
SignFormat
StructInitializer<T extends StructBase<T, K, V>, K extends Field<V>, V>
proxy over a map
TypedDataBuffer
TypedDataBuffer - BytesBuilderBuffer effectively, a fixed size BytesBuilder - allocated with a persistent buffer
TypedField<T extends NativeType>
StructField/NativeKey/StructKey, Typed 0,1,2,4,8 bytes
Uaccum16
Ufract16
Uint16
Represents a native unsigned 16 bit integer in C.
Uint16Int
Uint32
Represents a native unsigned 32 bit integer in C.
Uint32Int
Uint64
Represents a native unsigned 64 bit integer in C.
Uint8
Represents a native unsigned 8 bit integer in C.
Uint8Int
Version<K extends WordField<NativeType>>
4 fields optional, major, minor, fix by default, 1 or 2 bytes each parameterize T to constrain functions of T key to types the Version is defined with
VersionPrototype<K extends WordField<NativeType>>
protype objecct. flexible keys
VersionStandard
standard version with fixed keys and 1 byte fields, for common use. flexible keys and field sizes can be implemented with VersionConstruct.
WordBase<T extends WordBase<T, K>, K extends WordField<NativeType>>
WordStructBase — abstract base for user-defined word struct subtypes.
WordField<V extends NativeType>
a field within a WordStruct interface for including TypedField<T>, Enum type ensures bitmask is power of 2

Mixins

Immutable<S extends Immutable<S>>
optional
Serializable<S extends Serializable<S>>
Serializable - mixin in 1 step for serialization provide toMap or implements MapBase and duplicate code until combine mixin is support mixin toMap implmenting Map would require subclasses to mixin MapBase
StructBase<S extends StructBase<S, K, V>, K extends Field<V>, V>
StructBase — abstract base user subtype

Extension Types

BitForm
BitForm — zero-cost wrapper over a List<K> field schema. Analogue of StructForm for the bit domain. BitForm<K>(K.values).cast(ConstBits(raw as Bits));
Bitmasks
Bits
Bits - Bitwise operations on int function of a single number, object methods over top level math functions
BitStruct
BitStruct — zero-cost keyed view over a BitData object.
ByteForm
ByteStruct
ByteStruct is a TypedData with keyed/named access to fields. TypedData + [] Map operators returning int keyed view mixin keyed access for serialization map
EnumMap
EnumMap A Map with the additional constraint that Keys are a fixed set, via Enum. creation implements FixedMap/IndexMap constraints factory constructors build IndexMap by default wrap String handling via .name around IndexMap. Adds Serialization using Enum.name to a Map, Keys inherit from Enum - index via Enum.index -> create a parallel array map by default String name via Enum.name -> directly use for serialization
EnumMapFactory
construct a Map<K extends Enum, V> from Map<String, V> on creation ensure all fields are valid
NumDataScale
StructData
StructData — zero-cost keyed view over an existing object.
StructForm
StructForm StructData TypeClass Common viewer interface handle creation, creation here gurantees all keys are 'Struct' keys are present Conversion — bridge to Map (and therefore to serialization)
Word
Word - A register width variable. Implementation of Bits with byte granularity constructors/accessors. Effectively ByteData with a length of 8 bytes. Can be compile time constant, use as enum entry
WordForm
WordStruct
Bits/Word + keys [] Map operators returning int

Extensions

BitFieldMapMethods on BitFieldMap<K>
BitIndexKeysMethods on Iterable<BitIndexField>
BitmasksMethods on Iterable<Bitmask>
ByteDataArrayAccess on ByteData
ByteDataWordAccess on ByteData
EnumMapByName on Map<K, V>
Serialization of Map<Enum, V> interface Methods on loose contraints Map<Enum, V> Enum.name base methods are applicable regardless of EnumMap FixedMap constraints add fills existing Map only
EnumNamedValues on Iterable<MapEntry<K, V>>
Extensions
IntToBits on int
NumDataConversionOperators on NumDataConversion
PacketIdMethods on PacketId
SerializableKeys on StructForm<K, V>
SerializableMethods on Serializable<Serializable>
SerializableNullableType on StructForm<K, Object?>
SerializableValueObjects on StructForm<K, Object>
SizedWord on ByteData
TypedDataCast on TypedData
sublistView using length instead of end Effectively moving up ByteBuffer layer, to TypedData view segment accounting for this.offsetInBytes
TypedDataLength on TypedData
implementations on TypedData returning as this type parameters in element size of this type
TypedDataListSeek on T
TypedList version of List<int>.skip
TypedDataSlices on T
Slices returning TypedData Slices on List cannot return TypedData
TypedDataToInt on TypedData
TypedStructReference on ({StructData<K, V> data, StructForm<K, V> type})
return context with both keys and data StructForm(PersonField.values)(personA).toMap();

Functions

bytesPerElementOf<T extends TypedData>() int
fromListInt<T extends TypedDataList<int>>(List<int> elements) → T
sublistView<T extends TypedData>(TypedData data, [int start = 0, int? end]) → T
GenericSublistView offset in elements, type of data, not T type.
typedList<T extends TypedDataList>(int length) → T
Wrappers as top level functions

Typedefs

BitFieldEntry<K extends BitField> = StructField<K, int>
DataDecoder<T> = T Function(int data)
DataEncoder<T> = int Function(T view)
DataOfNum = int Function(num view)
EnumInt16<V extends Enum> = EnumOffsetFormat<Int16, V>
EnumInt32<V extends Enum> = EnumOffsetFormat<Int32, V>
EnumInt8<V extends Enum> = EnumOffsetFormat<Int8, V>
EnumUint<V extends Enum> = EnumFormat<NativeType, V>
FieldMap<K extends Field<V>, V> = Map<K, V>
Integer16 = IntFormat<Int16>
Raw integer pass-through
Integer16U = IntFormat<Uint16>
NumDataConversion = ({DataOfNum dataOfView, NumOfData viewOfData})
NumOfData = num Function(int data)
Numeric value conversion
PacketCaster<P extends Packet> = P Function(TypedData typedData)
PayloadCaster<V> = Payload<V> Function(TypedData typedData)
Payload Constructor - handler per id Struct.create<T>
SerializableEntry<V> = ({SerializableField<V> key, V value})
StructField<K extends Field<V>, V> = ({K key, V value})
TypedDataCaster<T> = T Function(TypedData typedData)
T is ByteStruct or ffi.Struct