final class StreamDecoder[+A] extends AnyRef
Supports binary decoding of a stream that emits elements as they are decoded.
The main purpose of using a StreamDecoder
over a scodec.Decoder
is mixing
decoding 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 be
emitted 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 StreamDecoder
companion has various constructors -- most importantly, once
and many
, that allow a Decoder[A]
to be lifted to a StreamDecoder[A]
.
Given a StreamDecoder[A]
, a bit stream can be decoded via the decode
method or
by calling a variant of toPipe
.
- Self Type
- StreamDecoder[A]
- Source
- StreamDecoder.scala
- Alphabetic
- By Inheritance
- StreamDecoder
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def ++[A2 >: A](that: => StreamDecoder[A2]): StreamDecoder[A2]
Creates a stream decoder that first decodes until this decoder finishes and then decodes using the supplied decoder.
Creates a stream decoder that first decodes until this decoder finishes and then decodes using the supplied decoder.
Note: this should not be used to write recursive decoders (e.g.,
def ints: StreamDecoder[A] = once(int32) ++ ints
) if each incremental decoding step can fail withInsufficientBits
. Otherwise, it decoding can get stuck in an infinite loop, where the remaining bits are fed to the recursive call. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply[F[_]](s: Stream[F, BitVector])(implicit arg0: RaiseThrowable[F]): Pull[F, A, Option[Stream[F, BitVector]]]
Returns a
Pull[F, A, Option[Stream[F, BitVector]]]
given aStream[F, BitVector]
.Returns a
Pull[F, A, Option[Stream[F, BitVector]]]
given aStream[F, BitVector]
. The result of the returned pull is the remainder of the input stream that was not used in decoding. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def decode[F[_]](s: Stream[F, BitVector])(implicit arg0: RaiseThrowable[F]): Stream[F, A]
Returns a
Stream[F, A]
given aStream[F, BitVector]
. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[B](f: (A) => StreamDecoder[B]): StreamDecoder[B]
Creates a stream decoder that, upon decoding an
A
, applies it to the supplied function and decodes the next part of the input with the returned decoder.Creates a stream decoder that, upon decoding an
A
, applies it to the supplied function and decodes 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. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def handleErrorWith[A2 >: A](f: (Throwable) => StreamDecoder[A2]): StreamDecoder[A2]
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isolate(bits: Long): StreamDecoder[A]
Alias for
StreamDecoder.isolate(bits)(this)
. - def map[B](f: (A) => B): StreamDecoder[B]
Maps the supplied function over each output of this decoder.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def strict: Decoder[Vector[A]]
Converts this stream decoder to a
Decoder[Vector[A]]
. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toPipe[F[_]](implicit arg0: RaiseThrowable[F]): Pipe[F, BitVector, A]
Converts this decoder to a
Pipe[F, BitVector, A]
. - def toPipeByte[F[_]](implicit arg0: RaiseThrowable[F]): Pipe[F, Byte, A]
Converts this decoder to a
Pipe[F, Byte, A]
. - def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()