LowPriorityCodec

sttp.tapir.LowPriorityCodec

Lower-priority codec implicits, which transform other codecs. For example, when deriving a codec List[T] <-> Either[A, B], given codecs ca: T <-> A and cb: T <-> B, we want to get listHead(eitherRight(ca, cb)), not eitherRight(listHead(ca), listHead(cb)) (although they would function the same).

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Codec.type
Self type
Codec.type

Members list

Value members

Concrete methods

def eitherLeft[L, A, B, CF <: CodecFormat](c1: Codec[L, A, CF], c2: Codec[L, B, CF]): Codec[L, Either[A, B], CF]

Create a codec which during decoding, first tries to decode values on the left using c1. If this fails for any reason, decoding is done using c2. Both codecs must have the same low-level values and formats.

Create a codec which during decoding, first tries to decode values on the left using c1. If this fails for any reason, decoding is done using c2. Both codecs must have the same low-level values and formats.

For a right-biased variant see Codec.eitherRight.

The schema is defined to be an either schema as created by Schema.schemaForEither.

Attributes

Implicits

Implicits

implicit def eitherRight[L, A, B, CF <: CodecFormat](implicit c1: Codec[L, A, CF], c2: Codec[L, B, CF]): Codec[L, Either[A, B], CF]

Create a codec which during decoding, first tries to decode values on the right using c2. If this fails for any reason, decoding is done using c1. Both codecs must have the same low-level values and formats.

Create a codec which during decoding, first tries to decode values on the right using c2. If this fails for any reason, decoding is done using c1. Both codecs must have the same low-level values and formats.

For a left-biased variant see Codec.eitherLeft. This right-biased version is the default when using implicit codec resolution.

The schema is defined to be an either schema as created by Schema.schemaForEither.

Attributes