StringDecoder
Provides instance creation and summing methods for StringDecoder.
Default StringDecoder instances are provided in codecs.
Attributes
- Graph
-
- Supertypes
- Self type
-
StringDecoder.type
Members list
Value members
Concrete methods
Creates a safe decoding function from the specified unsafe one.
Creates a safe decoding function from the specified unsafe one.
This method expects the specified decoding function to be able to fail by throwing exceptions. These will be caught and wrapped in DecodeError.
This is typically used in conjunction with [StringDecoder.from], when creating instances for types that are not isomorphic to String
.
Type parameters
- D
-
decoded type.
Value parameters
- f
-
decoding function.
- typeName
-
name of the decoded type (used in error messages).
Attributes
- Example
-
scala> val decoder = StringDecoder.makeSafe("Int")(_.toInt) scala> decoder("1") res1: StringResult[Int] = Right(1) scala> decoder("foobar") res2: StringResult[Int] = Left(DecodeError: 'foobar' is not a valid Int)
Inherited methods
Summons an implicit instance of Decoder if one is found, fails compilation otherwise.
Summons an implicit instance of Decoder if one is found, fails compilation otherwise.
This is a slightly faster, less verbose version of implicitly
.
Attributes
- Inherited from:
- DecoderCompanion
Creates a StringDecoder instance for java.util.Date
.
Creates a StringDecoder instance for java.util.Date
.
Attributes
- Inherited from:
- PlatformSpecificDecoders
Creates a new Decoder instance from the specified function.
Creates a new Decoder instance from the specified function.
Attributes
- Inherited from:
- DecoderCompanion
Attributes
- Inherited from:
- DecoderCompanion
Creates a new Decoder instance from the specified function.
Creates a new Decoder instance from the specified function.
This method turns the specified function safe. The error message might end up being a bit generic though - use from if you want to deal with errors explicitly.
Attributes
- Inherited from:
- DecoderCompanion
Creates a new Decoder instance from the specified alternatives.
Creates a new Decoder instance from the specified alternatives.
When decoding, each of the specified decoders will be attempted. The result will be the first success if found, or the last failure otherwise.
Attributes
- Inherited from:
- DecoderCompanion