A streaming decoding process, represented as a stream of state actions on scodec.bits.BitVector.
A streaming decoding process, represented as a stream of state
actions on scodec.bits.BitVector. Most clients will typically
use one of the decoding convenience methods on this class, rather
than using decoder
directly.
Advance the input by the given number of bits, purely as an effect.
Obtain the current input.
Obtain the current input. This stream returns a single element.
Advance the input by the given number of bits.
The decoder that consumes no input, emits the given a
, then halts.
The decoder that consumes no input, emits the given A
values, then halts.
The decoder that consumes no input and halts with the given error.
The decoder that consumes no input and halts with the given error.
The decoder that consumes no input and emits no values.
Run the given StreamDecoder
using only the first numberOfBits
bits of
the current stream, then advance the cursor by that many bits on completion.
Run the given StreamDecoder
using only the first numberOfBytes
bytes of
the current stream, then advance the cursor by that many bytes on completion.
Parse a stream of A
values from the input, using the given decoder.
Parse a stream of A
values from the input, using the given decoder.
The returned stream terminates normally if the final value decoded
exhausts in
and leaves no trailing bits. The returned stream terminates
with an error if the Decoder[A]
ever fails on the input.
Like scodec.stream.decode.many, but fails with an error if no elements are decoded.
Like scodec.stream.decode.many, but fails with an error if no elements are decoded. The returned stream will have at least one element if it succeeds.
Like many
, but reads up to chunkSize
elements from the stream at a time,
to minimize overhead.
Like many
, but reads up to chunkSize
elements from the stream at a time,
to minimize overhead. Since this "reads ahead" in the stream, it can't be
used predictably when the returned decoder will be interleaved with another
decoder, as in sepBy
, or any other combinator that uses tee
.
Modify the current input.
Modify the current input. This stream returns a single element.
Run the given Decoder
once and emit its result, if successful.
Runs p1
, then runs p2
if p1
emits no elements.
Runs p1
, then runs p2
if p1
emits no elements.
Example: or(tryOnce(codecs.int32), once(codecs.uint32))
.
This function does no backtracking of its own; backtracking
should be handled by p1
.
Run this decoder, but leave its input unconsumed.
Run this decoder, but leave its input unconsumed. Note that this requires keeping the current stream in memory for as long as the given decoder takes to complete.
Promote a decoder to a Process1
.
Promote a decoder to a Process1
. The returned Process1
may be
given chunks larger or smaller than what is needed to decode a single
element, and will buffer any unconsumed input, but a decoding error
will result if the decoder fails for a reason other than Err.InsufficientBits
.
This combinator relies on the decoder satisfying the following
property: If successful on input x
, A
should also succeed with the
same value given input x ++ y
, for any choice of y
. This ensures the
decoder can be given more input than it needs without affecting
correctness, and generally restricts this combinator to being used with
"self-delimited" decoders. Using this combinator with a decoder not
satisfying this property will make results highly dependent on the sequence
of chunk sizes passed to the process.
Like many
, but parses and ignores a D
delimiter value in between
decoding each A
value.
Like scodec.stream.decode.sepBy
, but fails with an error if no
elements are decoded.
Like scodec.stream.decode.sepBy
, but fails with an error if no
elements are decoded. The returned stream will have at least one
element if it succeeds.
Set the current cursor to the given BitVector
.
Produce a StreamDecoder
lazily.
Trim the input by calling take(n)
on the input BitVector
.
Like scodec.stream.decode.many, but in the event of a decoding error, resets cursor to end of last successful decode, then halts normally.
Like scodec.stream.decode.tryMany, but reads up to chunkSize
elements
at once.
Like scodec.stream.decode.tryMany, but reads up to chunkSize
elements
at once. As mentioned in scodec.stream.decode.manyChunks, the resulting
decoder cannot be meaningfully interleaved with other decoders.
Like scodec.stream.decode.once, but halts normally and leaves the input unconsumed in the event of a decoding error.
Like scodec.stream.decode.once, but halts normally and leaves the
input unconsumed in the event of a decoding error. tryOnce[A].repeat
will produce the same result as many[A]
, but allows.
Module containing various streaming decoding combinators. Decoding errors are represented using scodec.stream.decode.DecodingError.