StreamingUnpacker

This StreamingUnpacker is a MessagePack streaming deserializer

This implementation enables you to load multiple objects from a stream(like network).

Constructors

this
this(ubyte[] target, size_t bufferSize)

Constructs a StreamingUnpacker.

Members

Functions

clear
void clear()

Clears some states for next deserialization.

execute
bool execute()

Executes deserialization.

opApply
int opApply(int delegate(ref Unpacked) dg)

supports foreach. One loop provides Unpacked object contains execute() result. This is convenient in case that MessagePack values are continuous.

purge
Unpacked purge()

Convenient method for unpacking and clearing states.

Properties

unpacked
Unpacked unpacked [@property getter]

Forwards to deserialized object.

Mixed In Members

From mixin InternalBuffer

buffer
ubyte[] buffer [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
feed
void feed(ubyte[] target)
Undocumented in source.
bufferConsumed
void bufferConsumed(size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
removeUnparsed
void removeUnparsed()
Undocumented in source. Be warned that the author may not have intended to support it.
size
size_t size [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
parsedSize
size_t parsedSize [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
unparsedSize
size_t unparsedSize [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

...
auto unpacker = StreamingUnpacker(serializedData);
...

// appends new data to buffer if pre execute() call didn't finish deserialization.
unpacker.feed(newSerializedData);

while (unpacker.execute()) {
    foreach (obj; unpacker.purge()) {
        // do stuff (obj is a Value)
    }
}

if (unpacker.size)
    throw new Exception("Message is too large");

Meta