MessageDecoder

io.github.pidoveproject.showdown.protocol.MessageDecoder
See theMessageDecoder companion class

Attributes

Companion
class
Source
MessageDecoder.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def attempt[T](value: => T): MessageDecoder[T]

A decoder attempting to evaluate the given result.

A decoder attempting to evaluate the given result.

Type parameters

T

the result type

Value parameters

value

the result to evaluate

Attributes

Returns

a decoder succeeding with the passed result or failing if the result evaluation failed

See also
Source
MessageDecoder.scala
def attemptOrElse[T](value: => T, error: Throwable => ProtocolError): MessageDecoder[T]

A decoder attempting to evaluate the given result.

A decoder attempting to evaluate the given result.

Type parameters

T

the result type

Value parameters

error

the function to transform the thrown error into a ProtocolError

value

the result to evaluate

Attributes

Returns

a decoder succeeding with the passed result or failing with the given error if the result evaluation failed

See also
Source
MessageDecoder.scala
inline def derived[T](using m: Of[T]): MessageDecoder[T]

Derive a decoder from a case class or an enum.

Derive a decoder from a case class or an enum.

Type parameters

T

the result type

Value parameters

m

the mirror representing the result type

Attributes

Returns

a decoder automatically generated for the type T

Source
MessageDecoder.scala
def fail(error: ProtocolError): MessageDecoder[Nothing]

Create an always-failing decoder.

Create an always-failing decoder.

Value parameters

error

the error of the decoder

Attributes

Returns

a decoder that always fail with the passed error

Source
MessageDecoder.scala
def fromEither[T](value: Either[ProtocolError, T]): MessageDecoder[T]

Create a decoder from an either.

Create a decoder from an either.

Type parameters

T

the result type

Value parameters

value

the error or succeeding result

Attributes

Returns

a decoder succeeding with the right result or failing with the left error

Source
MessageDecoder.scala
def fromJson[A : JsonDecoder]: MessageDecoder[A]

Create a decoder from a JsonDecoder

Create a decoder from a JsonDecoder

Attributes

Source
MessageDecoder.scala
def fromOption[T](value: Option[T]): MessageDecoder[T]

Create a decoder from an optional value.

Create a decoder from an optional value.

Type parameters

T

the result type of the decoder

Value parameters

value

the optional value to pass if exists.

Attributes

Returns

a decoder succeeding with the current value or failing if the passed value is None

Source
MessageDecoder.scala
def oneOf(values: String*): MessageDecoder[String]

A decoder accepting one of the given keywords.

A decoder accepting one of the given keywords.

Value parameters

values

the accepted keywords

Attributes

Returns

a decoder resulting in the parsed keyword

Source
MessageDecoder.scala
def succeed[T](value: T): MessageDecoder[T]

Create an always-succeeding decoder.

Create an always-succeeding decoder.

Type parameters

T

the result type

Value parameters

value

the result of the decoder

Attributes

Returns

a decoder that always succeeds with the passed value

Source
MessageDecoder.scala
def word(value: String): MessageDecoder[String]

A decoder accepting a keyword.

A decoder accepting a keyword.

Value parameters

value

the keyword to decode

Attributes

Returns

a decoder resulting in the passed keyword as String

Source
MessageDecoder.scala

Concrete fields

val next: MessageDecoder[String]

Attributes

Source
MessageDecoder.scala

Givens

Givens

given boolean: MessageDecoder[Boolean]

Attributes

Source
MessageDecoder.scala
given char: MessageDecoder[Char]

Attributes

Source
MessageDecoder.scala
inline given derivedUnion[T](using m: UnionTypeMirror[T]): MessageDecoder[T]

Derive a decoder from an union type.

Derive a decoder from an union type.

Type parameters

T

the result type (union)

Value parameters

m

the mirror representing the union type

Attributes

Returns

a decoder automatically generated for the type T

Source
MessageDecoder.scala
given double: MessageDecoder[Double]

Attributes

Source
MessageDecoder.scala
given emptyTuple: MessageDecoder[EmptyTuple]

Attributes

Source
MessageDecoder.scala
given int: MessageDecoder[Int]

Attributes

Source
MessageDecoder.scala
inline given ironType[A, C](using inline decoder: MessageDecoder[A], constraint: Constraint[A, C]): MessageDecoder[IronType[A, C]]

Attributes

Source
MessageDecoder.scala
given list[A](using decoder: MessageDecoder[A]): MessageDecoder[List[A]]

Attributes

Source
MessageDecoder.scala
given long: MessageDecoder[Long]

Attributes

Source
MessageDecoder.scala
inline given newtype[T](using mirror: Mirror[T]): MessageDecoder[T]

Attributes

Source
MessageDecoder.scala
given nonEmptyTuple[A, T <: Tuple](using headDecoder: MessageDecoder[A], tailDecoder: MessageDecoder[T]): MessageDecoder[A *: T]

Attributes

Source
MessageDecoder.scala
given option[A](using decoder: MessageDecoder[A]): MessageDecoder[Option[A]]

Attributes

Source
MessageDecoder.scala
given string: MessageDecoder[String]

Attributes

Source
MessageDecoder.scala

Extensions

Extensions

extension [R](either: Either[String, R])
def toInvalidInput(input: String): Either[ProtocolError, R]

Transforms the error message of this Either to a ProtocolError

Transforms the error message of this Either to a ProtocolError

Attributes

Source
MessageDecoder.scala
extension (value: String)
def decode[T](using decoder: MessageDecoder[T]): Either[ProtocolError, T]

Decode the value.

Decode the value.

Attributes

Returns

either a succeeding result or an error if the decoding failed

Source
MessageDecoder.scala