Attempts to decode a value of type A
from the specified bit vector.
Attempts to decode a value of type A
from the specified bit vector.
bits to decode
error if value could not be decoded or the remaining bits and the decoded value
Attempts to encode the specified value in to a bit vector.
Attempts to encode the specified value in to a bit vector.
value to encode
When called on a Codec[L]
for some L <: HList
, returns a new codec that encodes/decodes
the HList L
followed by a B
.
When called on a Codec[L]
for some L <: HList
, returns a new codec that encodes/decodes
the HList L
followed by a B
.
That is, this operator is a codec-level HList
append operation.
When called on a Codec[A]
where A
is not a subytpe of HList
, creates a new codec that encodes/decodes an HList
of B :: A :: HNil
.
When called on a Codec[A]
where A
is not a subytpe of HList
, creates a new codec that encodes/decodes an HList
of B :: A :: HNil
.
For example,
uint8 :: utf8
has type Codec[Int :: String :: HNil]
.
uint8 :: utf8
}}}
When called on a Codec[L]
for some L <: HList
, returns a new codec representing Codec[B :: L]
.
When called on a Codec[L]
for some L <: HList
, returns a new codec representing Codec[B :: L]
.
That is, this operator is a codec-level HList
prepend operation.
codec to prepend
When called on a Codec[L]
for some L <: HList
, returns a new codec the encodes/decodes
the HList K
followed by the HList L
.
When called on a Codec[L]
for some L <: HList
, returns a new codec the encodes/decodes
the HList K
followed by the HList L
.
When called on a Codec[A]
, returns a new codec that encodes/decodes B :: A :: HNil
.
When called on a Codec[A]
, returns a new codec that encodes/decodes B :: A :: HNil
.
HList equivalent of ~>
.
When called on a Codec[L]
for some L <: HList
, returns a new codec that encodes/decodes
B :: L
but only returns L
.
When called on a Codec[L]
for some L <: HList
, returns a new codec that encodes/decodes
B :: L
but only returns L
. HList equivalent of ~>
.
Creates a Codec[A]
that: encodes an A
followed by the zero element of the Monoid
of B
;
decodes an A
followed by a B
and discards the decoded B
.
Creates a Codec[A]
that: encodes an A
followed by the zero element of the Monoid
of B
;
decodes an A
followed by a B
and discards the decoded B
.
Operator alias of dropRight.
Creates a new codec that encodes/decodes an HList
type of A :: L
given a function A => Codec[L]
.
Creates a new codec that encodes/decodes an HList
type of A :: L
given a function A => Codec[L]
.
This allows later parts of an HList
codec to be dependent on earlier values.
Operator alias for flatPrepend
.
Returns a new codec that encodes/decodes a value of type (A, B)
where the codec of B
is dependent on A
.
Returns a new codec that encodes/decodes a value of type (A, B)
where the codec of B
is dependent on A
.
Operator alias for flatZip.
Returns a new codec that encodes/decodes a value of type B
by using an isomorphism between A
and B
.
Returns a new codec that encodes/decodes a value of type B
by using an isomorphism between A
and B
.
The isomorphism is provided by the implicit CodecAsAux
instance.
Typically used when B
is a case class and A
is an HList
with the same shape as the elements of B
.
Converts this codec to a new codec that compacts the encoded bit vector before returning it.
Converts this codec to a new codec that fails decoding if there are remaining bits.
Converts this GenCodec
to a GenCodec[C, B]
using the supplied C => A
.
Decodes a value of type A
from the specified bit vector and discards any
remaining bits, throwing an IllegalArgumentException
if an error occurs.
Decodes a value of type A
from the specified bit vector and discards any
remaining bits, throwing an IllegalArgumentException
if an error occurs.
bits to decode
the decoded value
if a decoding error occurs
Attempts to decode a value of type A
from the specified bit vector and discards any
remaining bits.
Attempts to decode a value of type A
from the specified bit vector and discards any
remaining bits.
bits to decode
error if value could not be decoded or the decoded value
Creates a Codec[B]
that: encodes the zero element of the Monoid
of A followed by a
B;
decodes an
A followed by a
B and discards the decoded
A.
Creates a Codec[A]
that: encodes an A
followed by the zero element of the Monoid
of B
;
decodes an A
followed by a B
and discards the decoded B
.
Creates a new codec with all unit values filtered out.
Creates a new codec with all unit values filtered out.
Encodes the specified value in to a bit vector, throwing an
IllegalArgumentException
if encoding fails.
Encodes the specified value in to a bit vector, throwing an
IllegalArgumentException
if encoding fails.
value to encode
upon encoding failure
Converts this decoder to a Decoder[B]
using the supplied A => Decoder[B]
.
Converts this decoder to a Decoder[B]
using the supplied A => Decoder[B]
.
Creates a new codec that encodes/decodes an HList
type of A :: L
given a function A => Codec[L]
.
Creates a new codec that encodes/decodes an HList
type of A :: L
given a function A => Codec[L]
.
This allows later parts of an HList
codec to be dependent on earlier values.
Returns a new codec that encodes/decodes a value of type (A, B)
where the codec of B
is dependent on A
.
Creates a new codec that encodes/decodes an HList
type of A :: B :: HNil
given a function A => Codec[B]
.
Creates a new codec that encodes/decodes an HList
type of A :: B :: HNil
given a function A => Codec[B]
.
If B
is an HList
type, consider using flatPrepend
instead, which avoids nested HLists
.
This is the direct HList
equivalent of flatZip
.
Converts this generalized codec in to a non-generalized codec assuming A
and B
are the same type.
Converts this generalized codec in to a non-generalized codec assuming A
and B
are the same type.
Lifts this codec in to a codec of a singleton hlist.
Converts this GenCodec
to a GenCodec[A, C]
using the supplied B => C
.
Creates a Codec[(A, B)]
that first encodes/decodes an A
followed by a B
.
Converts this encoder to an Encoder[B]
using the supplied partial
function from B
to A
.
Converts this encoder to an Encoder[B]
using the supplied partial
function from B
to A
. The encoding will fail for any B
that
f
maps to None
.
Polymorphic function version of xmap
.
Polymorphic function version of xmap
.
When called on a Codec[A]
where A
is not a subytpe of HList
, returns a new codec that's the result of
xmapping with p
and q
, using p
to convert from A
to B
and using q
to convert from
B
to A
.
polymorphic function that converts from A
to B
polymorphic function that converts from B
to A
Polymorphic function version of xmap
.
Polymorphic function version of xmap
.
When called on a Codec[L]
for some L <: HList
, returns a new codec that's the result of
xmapping with p
and q
, using p
to convert from L
to M
and using q
to convert from
M
to L
.
polymorphic function that converts from L
to M
polymorphic function that converts from M
to L
Polymorphic function version of xmap
that uses a single polymorphic function in both directions.
Polymorphic function version of xmap
that uses a single polymorphic function in both directions.
When called on a Codec[A]
where A
is not a subytpe of HList
, returns a new codec that's the result of
xmapping with p
for both forward and reverse directions.
polymorphic function that converts from A
to B
and from B
to A
Polymorphic function version of xmap
that uses a single polymorphic function in both directions.
Polymorphic function version of xmap
that uses a single polymorphic function in both directions.
When called on a Codec[L]
for some L <: HList
, returns a new codec that's the result of
xmapping with p
for both forward and reverse directions.
polymorphic function that converts from L
to M
and from M
to L
Maps to a codec
of type B
, where there is a partial function
from B
to A
.
Maps to a codec
of type B
, where there is a partial function
from B
to A
. The encoding will fail for any B
that
g
maps to None
.
Converts this to a Codec[Unit]
that encodes using the specified zero value and
decodes a unit value when this codec decodes an A
successfully.
Converts this to a Codec[Unit]
that encodes using the zero value of the implicitly
available Monoid[A]
and decodes a unit value when this codec decodes an A
successfully.
Creates a new codec that is functionally equivalent to this codec but returns the specified string from toString
.
Maps to a codec of type B
using two total functions, A => B
and B => A
.
Creates a Codec[(A, B)]
that first encodes/decodes an A
followed by a B
.
Creates a Codec[(A, B)]
that first encodes/decodes an A
followed by a B
.
Operator alias for pairedWith.
Creates a Codec[B]
that: encodes the zero element of the Monoid
of A followed by a
B;
decodes an
A followed by a
B and discards the decoded
A.
Creates a Codec[B]
that: encodes the zero element of the Monoid
of A followed by a
B;
decodes an
A followed by a
B and discards the decoded
A.
Operator alias of dropLeft.
(codec: ValueCodecEnrichedWithHListSupport[A]).self
(codec: HListCodecEnrichedWithHListSupport[A]).self
Supports encoding a value of type
A
to aBitVector
and decoding aBitVector
to a value ofA
.Not every value of
A
can be encoded to a bit vector and similarly, not every bit vector can be decoded to a value of typeA
. Hence, both encode and decode return either an error or the result. Furthermore, decode returns the remaining bits in the bit vector that it did not use in decoding.Note: the decode function can be lifted to a state action via
StateT[String \/ ?, BitVector, A]
. This type alias and associated constructor is provided byDecodingContext
.