msgpack-lite icon indicating copy to clipboard operation
msgpack-lite copied to clipboard

Is it possible to read only one msgpack (ie. a header) from a stream, then leave the rest intact?

Open stuartpb opened this issue 8 years ago • 2 comments

I'm looking at the streaming interface, but one thing isn't clear to me: is it possible to pipe a file stream to a decoder stream to read a msgpack value in the file, then unpipe it and begin reading the rest of the file immediately from the octet following the msgpack value, outside the context of a msgpack stream?

stuartpb avatar May 26 '17 08:05 stuartpb

The simplest way I can think to do this is to add a bottleneck on the stream going into the DecodeStream that breaks each chunk into a series of chunks byte-by-byte, then unpipes after the finishing byte that causes an object to be emitted.

However, I'm wondering if there's another way, such as a modification to the flush method (and/or the fetch method) that would allow for another method that could be called to get any buffered data that ha yet to be flushed, in the middle of the first call of the DecodeStream's data callback.

stuartpb avatar May 26 '17 09:05 stuartpb

The dryrun measuring feature described in #40 could also be useful here.

stuartpb avatar May 26 '17 09:05 stuartpb