StreamDecoder
Supports binary decoding of a stream that emits elements as they are decoded.
The main purpose of using a
decoding with processing. For example,
could be used to decode a bit stream but the decoded
emitted until the end of the bit stream. With
each decoded
StreamDecoder
over an scodec.Decoder
is mixingdecoding with processing. For example,
scodec.codecs.vector(decoderA): Decoder[Vector[A]]
could be used to decode a bit stream but the decoded
Vector[A]
would not beemitted until the end of the bit stream. With
StreamDecoder.many(decoderA): StreamDecoder[A]
,each decoded
A
value is emitted as soon as it is decoded.The
and
StreamDecoder
companion has various constructors -- most importantly, once
and
many
, that allow a Decoder[A]
to be lifted to a StreamDecoder[A]
.Given a
by calling a variant of
StreamDecoder[A]
, a bit stream can be decoded via the decode
method orby calling a variant of
toPipe
.- Companion
- object
class Object
trait Matchable
class Any
Value members
Methods
def decode[F <: ([_$5] =>> Any)](s: Stream[F, BitVector])(evidence$3: RaiseThrowable[F]): Stream[F, A]
Returns a
Stream[F, A]
given a Stream[F, BitVector]
. def apply[F <: ([_$6] =>> Any)](s: Stream[F, BitVector])(evidence$4: RaiseThrowable[F]): Pull[F, A, Option[Stream[F, BitVector]]]
Returns a
The result of the returned pull is the remainder of the input stream that was not used in decoding.
Pull[F, A, Option[Stream[F, BitVector]]]
given a Stream[F, BitVector]
.The result of the returned pull is the remainder of the input stream that was not used in decoding.
Creates a stream decoder that, upon decoding an
the next part of the input with the returned decoder. When that decoder finishes, the remainder of
the input is returned to the original decoder for further decoding.
A
, applies it to the supplied function and decodesthe next part of the input with the returned decoder. When that decoder finishes, the remainder of
the input is returned to the original decoder for further decoding.
Creates a stream decoder that first decodes until this decoder finishes and then decodes
using the supplied decoder.
using the supplied decoder.
Note: this should not be used to write recursive decoders (e.g.,
if each incremental decoding step can fail with
an infinite loop, where the remaining bits are fed to the recursive call.
def ints: StreamDecoder[A] = once(int32) ++ ints
)if each incremental decoding step can fail with
InsufficientBits
. Otherwise, it decoding can get stuck inan infinite loop, where the remaining bits are fed to the recursive call.