Trait/Object

kantan.codecs

Decoder

Related Docs: object Decoder | package codecs

Permalink

trait Decoder[E, D, F, T] extends Serializable

Type class for types that can be decoded from other types.

E

encoded type - what to decode from.

D

decoded type - what to decode to.

F

failure type - how to represent errors.

T

tag type - used to specialise decoder instances, and usually where default implementations are declared.

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Decoder
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def decode(e: E): Either[F, D]

    Permalink

    Decodes encoded data.

    Decodes encoded data.

    This method is safe, in that it won't throw for run-of-the-mill errors. Unrecoverable errors such as out of memory exceptions are still thrown, but that's considered valid exceptional cases, where incorrectly encoded data is just... normal.

    Callers that wish to fail fast and fail hard can use the unsafeDecode method instead.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def andThen[FF, DD](f: (Either[F, D]) ⇒ Either[FF, DD]): Decoder[E, DD, FF, T]

    Permalink

    Creates a new Decoder instance by transforming raw results with the specified function.

    Creates a new Decoder instance by transforming raw results with the specified function.

    Most of the time, other combinators such as map should be preferred. andThen is mostly useful when one needs to turn failures into successes, and even then, recover or recoverWith are probably more directly useful.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def collect[DD](f: PartialFunction[D, DD])(implicit t: IsError[F]): Decoder[E, DD, F, T]

    Permalink

    Applies the specified partial function, turning all non-matches to failures.

    Applies the specified partial function, turning all non-matches to failures.

    You can think as collect as a bit like a filter and a map merged into one.

  8. def contramapEncoded[EE](f: (EE) ⇒ E): Decoder[EE, D, F, T]

    Permalink

    Creates a new Decoder instance by transforming encoded values with the specified function.

  9. def emap[DD](f: (D) ⇒ Either[F, DD]): Decoder[E, DD, F, T]

    Permalink

    Creates a new Decoder instance by transforming successful results with the specified function.

    Creates a new Decoder instance by transforming successful results with the specified function.

    This differs from map in that it allows the transformation function to fail.

  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def filter(f: (D) ⇒ Boolean)(implicit t: IsError[F]): Decoder[E, D, F, T]

    Permalink

    Turns all values that don't match the specified predicates into failures.

    Turns all values that don't match the specified predicates into failures.

    See collect if you wish to transform the values in the same call.

  13. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def flatMap[DD](f: (D) ⇒ Decoder[E, DD, F, T]): Decoder[E, DD, F, T]

    Permalink
    Annotations
    @SuppressWarnings()
  15. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  16. def handleErrorWith(f: (F) ⇒ Decoder[E, D, F, T]): Decoder[E, D, F, T]

    Permalink
  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. def leftMap[FF](f: (F) ⇒ FF): Decoder[E, D, FF, T]

    Permalink

    Creates a new Decoder instance by transforming errors with the specified function.

  20. def map[DD](f: (D) ⇒ DD): Decoder[E, DD, F, T]

    Permalink

    Creates a new Decoder instance by transforming successful results with the specified function.

    Creates a new Decoder instance by transforming successful results with the specified function.

    This differs from emap in that the transformation function cannot fail.

  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. def orElse[DD >: D](d: Decoder[E, DD, F, T]): Decoder[E, DD, F, T]

    Permalink

    Creates a new Decoder instance with a fallback decoder if the current one fails.

  25. def product[DD](decoder: Decoder[E, DD, F, T]): Decoder[E, (D, DD), F, T]

    Permalink
  26. def recover[DD >: D](pf: PartialFunction[F, DD]): Decoder[E, DD, F, T]

    Permalink

    Creates a new Decoder instance by transforming some failures into successes with the specified function.

  27. def recoverWith[DD >: D, FF >: F](pf: PartialFunction[F, Either[FF, DD]]): Decoder[E, DD, FF, T]

    Permalink

    Creates a new Decoder instance by transforming some failures with the specified function.

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. def tag[TT]: Decoder[E, D, F, TT]

    Permalink

    Changes the type with which the decoder is tagged.

    Changes the type with which the decoder is tagged.

    This makes it possible to share similar decoders across various libraries. Extracting values from strings, for example, is a common task for which the default implementation can be shared rather than copy / pasted.

    Annotations
    @SuppressWarnings()
  30. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  31. def unsafeDecode(e: E): D

    Permalink

    Decodes encoded data unsafely.

    Decodes encoded data unsafely.

    The main difference between this and decode is that the former throws exceptions when errors occur where the later safely encodes error conditions in its return type.

    decode should almost always be preferred, but this can be useful for code where crashing is an acceptable reaction to failure.

    Annotations
    @SuppressWarnings()
  32. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def mapError[FF](f: (F) ⇒ FF): Decoder[E, D, FF, T]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 0.2.0) Use leftMap instead

  2. def mapResult[DD](f: (D) ⇒ Either[F, DD]): Decoder[E, DD, F, T]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 0.2.0) Use emap instead

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped