RichTextCodec

sealed trait RichTextCodec[A]

A RichTextCodec is a more compositional version of TextCodec, which has similar power to traditional parser combinators / pretty printers. Although slower than the simpler text codecs, they can be utilized to parse structured information in HTTP headers, which in turn allows generating much better error messages and documentation than otherwise possible.

Companion:
object
class Object
trait Matchable
class Any

Value members

Concrete methods

final def <~(that: => RichTextCodec[Unit]): RichTextCodec[A]

Returns a new codec that is the sequential composition of this codec and the specified codec, but which only produces the value of this codec.

Returns a new codec that is the sequential composition of this codec and the specified codec, but which only produces the value of this codec.

final def ?!(label: String): Tagged[A]

Tags the codec with a label used in the documentation. The label will be used but not explained

Tags the codec with a label used in the documentation. The label will be used but not explained

final def ??(label: String): Tagged[A]

Tags the codec with a label used in the documentation

Tags the codec with a label used in the documentation

final def as[B](b: => B)(implicit ev: A =:= Unit): RichTextCodec[B]

Tranforms this constant unit codec to a constant codec of another type.

Tranforms this constant unit codec to a constant codec of another type.

final def asType[B](implicit ev: A =:= B): RichTextCodec[B]
final def collectOrFail(failure: String)(pf: PartialFunction[A, A]): RichTextCodec[A]
final def decode(value: CharSequence): Either[String, A]
final def describe: Doc

Constructs documentation for this rich text codec.

Constructs documentation for this rich text codec.

final def encode(value: A): Either[String, String]

Encodes a value into a string, or if this is not possible, fails with an error message.

Encodes a value into a string, or if this is not possible, fails with an error message.

final def optional(default: A): RichTextCodec[Option[A]]
final def singleton: RichTextCodec[NonEmptyChunk[A]]
final def tagged(label: String): Tagged[A]
final def taggedUnexplained(label: String): Tagged[A]
final def transform[B](f: A => B, g: B => A): RichTextCodec[B]
final def transformOrFail[B](f: A => Either[String, B], g: B => Either[String, A]): RichTextCodec[B]
final def transformOrFailLeft[B](f: A => Either[String, B], g: B => A): RichTextCodec[B]
final def transformOrFailRight[B](f: A => B, g: B => Either[String, A]): RichTextCodec[B]
final def unit(canonical: A): RichTextCodec[Unit]

Converts this codec of A into a codec of Unit by specifying a canonical value to use when an HTTP client needs to generate a value for this codec.

Converts this codec of A into a codec of Unit by specifying a canonical value to use when an HTTP client needs to generate a value for this codec.

final def validate(failure: String)(p: A => Boolean): RichTextCodec[A]

Attempts to validate a decoded value, or fails using the specified failure message.

Attempts to validate a decoded value, or fails using the specified failure message.

final def |[B](that: => RichTextCodec[B]): RichTextCodec[Either[A, B]]

Returns a new codec that is the fallback composition of this codec and the specified codec, preferring this codec, but falling back to the specified codec in the event of failure.

Returns a new codec that is the fallback composition of this codec and the specified codec, preferring this codec, but falling back to the specified codec in the event of failure.

final def ~[B](that: => RichTextCodec[B])(implicit combiner: Combiner[A, B]): RichTextCodec[Out]

Returns a new codec that is the sequential composition of this codec and the specified codec, producing the values of both as a tuple.

Returns a new codec that is the sequential composition of this codec and the specified codec, producing the values of both as a tuple.

final def ~>[B](that: => RichTextCodec[B])(implicit ev: A =:= Unit): RichTextCodec[B]

Returns a new codec that is the sequential composition of this codec and the specified codec, but which only produces the value of that codec.

Returns a new codec that is the sequential composition of this codec and the specified codec, but which only produces the value of that codec.

Concrete fields

lazy val repeat: RichTextCodec[Chunk[A]]