Handler

class Handler[A](expected: String, f: JsonEvent => Option[A]) extends Handler[JsonEvent, A]
trait Handler[JsonEvent, A]
class Object
trait Matchable
class Any

Value members

Concrete methods

def finish(): A
def step(in: JsonEvent): Either[A, Handler[JsonEvent, A]]

Inherited methods

def asTopLevelHandler(caller: SpacTraceElement): Handler[JsonEvent, A]

Wraps this handler as a "top level" handler, which will inject a SpacTraceElement (representing the current input or the "EOF" signal) to any exception is thrown by this handler when calling its step or finish methods.

Wraps this handler as a "top level" handler, which will inject a SpacTraceElement (representing the current input or the "EOF" signal) to any exception is thrown by this handler when calling its step or finish methods.

Used internally by Parser's parse methods.

Inherited from
Handler
def stepMany[C[_], In2 <: JsonEvent](inputs: C[In2])(C: Unconsable[C]): Either[(A, C[In2]), Handler[JsonEvent, A]]

Convenience function to call step on a sequence of inputs all at once. If the step returns a result, this method will return a Left containing that result and the remainder of the inputs that were not consumed. If the inputs run out before the handler returns a result from a step, this method will return a Right containing the latest state of the handler. This method will not call the handler's finish().

Convenience function to call step on a sequence of inputs all at once. If the step returns a result, this method will return a Left containing that result and the remainder of the inputs that were not consumed. If the inputs run out before the handler returns a result from a step, this method will return a Right containing the latest state of the handler. This method will not call the handler's finish().

In general, you won't call this method directly. Instead, use one of the Parser trait's parse methods.

Type Params
C

An Unconsable collection, i.e. List or cats.data.Chain

In2

Subtype of In, or In (to satisfy contravariance)

Value Params
C

Evidence that the inputs has a head/tail split operation

inputs

A sequence of inputs

Returns

Either the handler's result paired with the remaining inputs, or the new handler state

Inherited from
Handler