bin library

Typed binary data structures for Dart.

Classes

Bin<T>
A typed binary field backed by a binarize payload type.
BinaryContract<T>
The BinaryContract allows developers to define a strongly typed binary representation of a Dart class. If your Dart class contract changes, so will the binary contract, ensuring you never forget to change how the data is being read or stored.
Binned
A field that can read and write itself from positioned binary streams.
ByteBuffer
A sequence of bytes underlying a typed data object.
ByteData
A fixed-length, random-access sequence of bytes that also provides random and unaligned access to the fixed-width integers and floating point numbers represented by those bytes.
ByteReader
Provides a stream lined experience for reading binary data.
Bytes
Reads and write a list of bytes.
ByteWriter
Provides a stream lined experience for writing binary data.
Endian
Endianness of number representation.
Payload
Base class for the PayloadWriter and PayloadReader.
PayloadReader
A readable payload. It is capable of reading values from a binary representation into their corresponding PayloadTypes.
PayloadType<T>
The base class for any payload type. It is capable of reading and writing values to a PayloadWriter or PayloadReader.
PayloadWriter
A writeable payload. It is used by binarize to create a binary representation of a payload.
RawList<T>
Reads and write a raw list of type.
Uint8List
A fixed-length list of 8-bit unsigned integers.
UnionType<T extends Binnable, Id>
A payload type and field factory for a discriminated union.

Mixins

Binnable
A binary object described by an ordered list of fields.
Union
Marks a Binnable type as a discriminated union root.

Constants

boolean → const _Boolean
Converts a boolean into a single bit.
flags → const _Flags
Converts a list of 8 booleans into a single byte.
float32 → const _Float32
Converts a double into four bytes that represents a Float32 value.
float32x4 → const _Float32x4
Converts a Float32x4 into four float32 sets that represents a Float32x4 value.
float64 → const _Float64
Converts a double into eight bytes that represents a Float64 value.
float64x2 → const _Float64x2
Converts a Float64x2 into two float32 sets that represents a Float64x2 value.
int16 → const _Int16
Converts a integer into two bytes that represents an Int16 value.
int32 → const _Int32
Converts a integer into four bytes that represents an Int32 value.
int32x4 → const _Int32x4
Converts a Int32x4 into four int32 sets that represents an Int32x4 value.
int64 → const _Int64
Converts a integer into eight bytes that represents an Int64 value.
int8 → const _Int8
Converts an integer into a single byte that represents an Int8 value.
string → const _StringEncoding
Provide a subset of string encoders.
uint16 → const _Uint16
Converts a integer into two bytes that represents an unsigned Int16 value.
uint32 → const _Uint32
Converts a integer into four bytes that represents an unsigned Int32 value.
uint64 → const _Uint64
Converts a integer into eight bytes that represents an unsigned Int64 value.
uint8 → const _Uint8
Converts a integer into a single byte that represents an unsigned Int8 value.

Properties

string16 PayloadType<String>
Converts a string into an encoded UTF-8 list.
final
string32 PayloadType<String>
Converts a string into an encoded UTF-8 list.
final
string64 PayloadType<String>
Converts a string into an encoded UTF-8 list.
final
string8 PayloadType<String>
Converts a string into an encoded UTF-8 list.
final

Functions

binarize(PayloadWriter payload) Uint8List
Convert a PayloadWriter into a Uint8List of bytes.
byteData({PayloadType<int> lengthType = uint8}) PayloadType<ByteData>
Converts byte data into binary.
decode<T>(PayloadType<T> type, Uint8List bytes) → T
Decodes bytes into a value using type.
encode<T>(PayloadType<T> type, T value) Uint8List
Encodes value into binary bytes using type.
enumeration<T extends Enum>(List<T> values, {PayloadType<int> lengthType = uint8}) PayloadType<T>
Store an Enum as binary.
float32List({PayloadType<int> lengthType = uint8}) PayloadType<Float32List>
Converts a list of floats into binary.
float32x4List({PayloadType<int> lengthType = uint8}) PayloadType<Float32x4List>
Converts a list of Float32x4 into binary.
float64List({PayloadType<int> lengthType = uint8}) PayloadType<Float64List>
Converts a list of floats into binary.
float64x2List({PayloadType<int> lengthType = uint8}) PayloadType<Float64x2List>
Converts a list of Float64x2 into binary.
int16List({PayloadType<int> lengthType = uint8}) PayloadType<Int16List>
Converts a list of signed integers into binary.
int32List({PayloadType<int> lengthType = uint8}) PayloadType<Int32List>
Converts a list of signed integers into binary.
int32x4List({PayloadType<int> lengthType = uint8}) PayloadType<Int32x4List>
Converts a list of Int32x4 into binary.
int64List({PayloadType<int> lengthType = uint8}) PayloadType<Int64List>
Converts a list of signed integers into binary.
int8List({PayloadType<int> lengthType = uint8}) PayloadType<Int8List>
Converts a list of signed integers into binary.
list<T>(PayloadType<T> type, {PayloadType<int> lengthType = uint32}) PayloadType<List<T>>
Make the given type support a list of T.
map<K, V>(PayloadType<K> keyType, PayloadType<V> valueType, {PayloadType<int> lengthType = uint8}) PayloadType<Map<K, V>>
Store a map of K and V as binary data.
nil<T>(PayloadType<T> type) PayloadType<T?>
Make the given type accept null values as well.
nullable<T>(PayloadType<T> type) PayloadType<T?>
Make the given type accept null values as well.
obj<T extends Binnable>(T create()) PayloadType<T>
Creates a payload type for a Binnable object.
uint16List({PayloadType<int> lengthType = uint8}) PayloadType<Uint16List>
Converts a list of unsigned integers into binary.
uint32List({PayloadType<int> lengthType = uint8}) PayloadType<Uint32List>
Converts a list of unsigned integers into binary.
uint64List({PayloadType<int> lengthType = uint8}) PayloadType<Uint64List>
Converts a list of unsigned integers into binary.
uint8List({PayloadType<int> lengthType = uint8}) PayloadType<Uint8List>
Converts a list of unsigned integers into binary.