pro_mpack library
A high-performance MessagePack serialization and deserialization library with full extension support.
This library provides a high-level API for encoding and decoding MessagePack data, as well as access to the underlying Packer and Unpacker for more granular control.
For most use cases, the serialize and deserialize functions are sufficient. For advanced scenarios requiring custom extension registration with high-performance caching (O(1) lookups), use the MessagePack class.
Classes
- Float
- A wrapper for explicitly serializing a double as a 32-bit float.
- MessagePack
- A high-performance MessagePack codec with custom extension support.
- MessagePackGroup
- Builder for grouping multiple types under a single extension ID.
- MessagePackStreamTransformer
- A StreamTransformer that decodes a stream of MessagePack bytes into a stream of Dart objects.
Extension Types
Functions
-
deserialize(
Uint8List buffer, {DecodeExt? decodeExt}) → dynamic -
Deserializes a single value from a MessagePack
buffer. -
deserializeAll(
Uint8List buffer, {DecodeExt? decodeExt}) → List -
Deserializes all MessagePack objects from the provided
bufferinto a list. -
serialize(
Object? value, {EncodeExt? encodeExt, int initialBufferSize = 1024}) → Uint8List -
Serializes
valueinto the MessagePack binary format. -
serializeAll(
Iterable values, {EncodeExt? encodeExt, int initialBufferSize = 1024}) → Uint8List -
Serializes a sequence of
valuesinto a single MessagePack buffer.
Typedefs
- DecodeExt = dynamic Function(int type, int length, Unpacker unpacker)
- Called by the Unpacker when it encounters a MessagePack ext type.
-
Decoder<
T> = T Function(Unpacker unpacker, int length) -
Decodes bytes into a value of type
T. - EncodeExt = bool Function(dynamic value, Packer packer)
- Called by the Packer when it encounters a type it cannot natively handle.
-
Encoder<
T> = void Function(T value, Packer packer) -
Encodes a value of type
Tinto bytes.
Exceptions / Errors
- MessagePackConfigurationException
- Thrown when there's an error in the custom extension configuration.
- MessagePackException
- Base class for all exceptions thrown by the MessagePack library.
- MessagePackFormatException
- Thrown when the binary data does not conform to the MessagePack specification.
- MessagePackSizeException
- Thrown when a string, collection, or binary blob exceeds MessagePack limits.
- MessagePackUnsupportedTypeException
- Thrown when attempting to serialize an object that isn't supported.