org.sigilaris.core.codec.byte.ByteDecoder
See theByteDecoder companion object
Type class for decoding byte sequences to Scala values.
ByteDecoder is the inverse of ByteEncoder, reconstructing typed values from deterministic byte representations.
Decoding returns Either[DecodeFailure, DecodeResult[A]]:
- Left(failure): decoding failed with error message
- Right(result): successfully decoded value with remaining bytes
The remainder allows sequential decoding of multiple values from a single byte sequence.
Attributes
-
See also
-
ByteCodec for bidirectional encoding/decoding
types.md for detailed decoding rules per type
-
Companion
-
object
-
Source
-
ByteDecoder.scala
-
Graph
-
-
Supertypes
-
class Object
trait Matchable
class Any
-
Known subtypes
-
Members list
Decodes bytes to a value.
Decodes bytes to a value.
Value parameters
-
bytes
-
the byte sequence to decode
Attributes
-
Returns
-
Either failure or decoded value with remainder
-
Source
-
ByteDecoder.scala
Creates a new decoder with validation.
Creates a new decoder with validation.
Value parameters
-
f
-
function that may fail with DecodeFailure
Attributes
-
Returns
-
new decoder for type B
-
Example
-
val positiveDecoder = ByteDecoder[Long].emap { n =>
Either.cond(n > 0, n, DecodeFailure("Must be positive"))
}
-
Source
-
ByteDecoder.scala
Creates a new decoder by chaining decoders.
Creates a new decoder by chaining decoders.
Value parameters
-
f
-
function that creates a decoder based on decoded value
Attributes
-
Returns
-
new decoder for type B
-
Source
-
ByteDecoder.scala
Creates a new decoder by transforming the decoded value.
Creates a new decoder by transforming the decoded value.
Value parameters
-
f
-
function to transform decoded value
Attributes
-
Returns
-
new decoder for type B
-
Source
-
ByteDecoder.scala
Widens the decoder to a supertype.
Widens the decoder to a supertype.
Type parameters
-
AA
-
the supertype
Attributes
-
Returns
-
a decoder for the wider type
-
Source
-
ByteDecoder.scala