Trait/Object

play.api.libs.iteratee

Iteratee

Related Docs: object Iteratee | package iteratee

Permalink

trait Iteratee[E, +A] extends AnyRef

An Iteratee consumes a stream of elements of type E, producing a result of type A. The stream itself is represented by the Input trait. An Iteratee is an immutable data type, so each step in consuming the stream generates a new Iteratee with a new state.

At a high level, an Iteratee is just a function that takes a piece of input and returns either a final result or a new function that takes another piece of input. To represent this, an Iteratee can be in one of three states (see the play.api.libs.iteratee.Step trait): play.api.libs.iteratee.Done, which means it contains a result and potentially some unconsumed part of the stream; play.api.libs.iteratee.Cont, which means it contains a function to be invoked to generate a new Iteratee from the next piece of input; play.api.libs.iteratee.Error, which means it contains an error message and potentially some unconsumed part of the stream.

One would expect to transform an Iteratee through the Cont state N times, eventually arriving at either the Done or Error state.

Typically an play.api.libs.iteratee.Enumerator would be used to push data into an Iteratee by invoking the function in the play.api.libs.iteratee.Cont state until either 1) the iteratee leaves the Cont state or 2) the enumerator runs out of data.

The Iteratee does not do any resource management (such as closing streams); the producer pushing stuff into the Iteratee has that responsibility.+ * The state of an Iteratee (the current play.api.libs.iteratee.Step may not be available synchronously; it may be pending an asynchronous computation. This is the difference between Iteratee and Step.

E

Input type

A

Result type of this Iteratee

Self Type
Iteratee[E, A]
Source
Iteratee.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Iteratee
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def fold[B](folder: (Step[E, A]) ⇒ Future[B])(implicit ec: ExecutionContext): Future[B]

    Permalink

    Computes a promised value B from the state of the Iteratee.

    Computes a promised value B from the state of the Iteratee.

    The folder function will be run in the supplied ExecutionContext. Exceptions thrown by the folder function will be stored in the returned Promise.

    If the folder function itself is synchronous, it's better to use pureFold() instead of fold().

    folder

    a function that will be called on the current state of the iteratee

    ec

    the ExecutionContext to run folder within

    returns

    the result returned when folder is called

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. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  8. def feed[AA >: A](in: Input[E]): Future[Iteratee[E, AA]]

    Permalink

    Sends one element of input to the Iteratee and returns a promise containing the new Iteratee.

    Sends one element of input to the Iteratee and returns a promise containing the new Iteratee. The promise may or may not be completed already when it's returned (the iteratee may use an asynchronous operation to handle the input).

    in

    input being sent

  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def flatFold[B, C](done: (A, Input[E]) ⇒ Future[Iteratee[B, C]], cont: ((Input[E]) ⇒ Iteratee[E, A]) ⇒ Future[Iteratee[B, C]], error: (String, Input[E]) ⇒ Future[Iteratee[B, C]])(implicit ec: ExecutionContext): Iteratee[B, C]

    Permalink

    Like fold1, except flattens the result with Iteratee.flatten.

    Like fold1, except flattens the result with Iteratee.flatten.

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread.

  11. def flatFold0[B, C](folder: (Step[E, A]) ⇒ Future[Iteratee[B, C]])(implicit ec: ExecutionContext): Iteratee[B, C]

    Permalink

    Like fold, except flattens the result with Iteratee.flatten.

    Like fold, except flattens the result with Iteratee.flatten.

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread.

  12. def flatMap[B](f: (A) ⇒ Iteratee[E, B])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    On Done of this Iteratee, the result is passed to the provided function, and the resulting Iteratee is used to continue consuming input

    On Done of this Iteratee, the result is passed to the provided function, and the resulting Iteratee is used to continue consuming input

    If the resulting Iteratee of evaluating the f function is a Done then its left Input is ignored and its computed result is wrapped in a Done and returned

    f

    a function for transforming the computed result into an Iteratee

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread.

  13. def flatMapInput[B](f: (Step[E, A]) ⇒ Iteratee[E, B])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink
  14. def flatMapM[B](f: (A) ⇒ Future[Iteratee[E, B]])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    Like flatMap but allows the flatMap function to execute asynchronously.

    Like flatMap but allows the flatMap function to execute asynchronously.

    This is particularly useful if you want to do blocking operations, so that you can ensure that those operations execute in the right execution context, rather than the iteratee execution context, which would potentially block all other iteratee operations.

    f

    a function for transforming the computed result into an Iteratee

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread.

  15. def flatMapTraversable[B, X](f: (A) ⇒ Iteratee[E, B])(implicit p: (E) ⇒ TraversableLike[X, E], bf: CanBuildFrom[E, X, E], ec: ExecutionContext): Iteratee[E, B]

    Permalink

    Like flatMap except that it concatenates left over inputs if the Iteratee returned by evaluating f is a Done.

    Like flatMap except that it concatenates left over inputs if the Iteratee returned by evaluating f is a Done.

    f

    a function for transforming the computed result into an Iteratee

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread. Note: input concatenation is performed in the iteratee default execution context, not in the user-supplied context.

  16. def fold1[B](done: (A, Input[E]) ⇒ Future[B], cont: ((Input[E]) ⇒ Iteratee[E, A]) ⇒ Future[B], error: (String, Input[E]) ⇒ Future[B])(implicit ec: ExecutionContext): Future[B]

    Permalink

    This method provides the means to check on the state of the Iteratee and eventually extract a value in a Promise

    This method provides the means to check on the state of the Iteratee and eventually extract a value in a Promise

    done

    a function that will be called if the Iteratee is a Done

    cont

    a function that will be called if the Iteratee is a Cont

    error

    a function that will be called if the Iteratee is an Error

    ec

    The context to execute the supplied functions with. The context is prepared on the calling thread.

    returns

    a scala.concurrent.Future of a value extracted by calling the appropriate provided function

  17. def foldNoEC[B](folder: (Step[E, A]) ⇒ Future[B]): Future[B]

    Permalink

    A version of fold that runs folder in the current thread rather than in a supplied ExecutionContext, called in several places where we are sure the stack cannot overflow.

    A version of fold that runs folder in the current thread rather than in a supplied ExecutionContext, called in several places where we are sure the stack cannot overflow. This method is designed to be overridden by StepIteratee, which can execute the folder function immediately.

    Attributes
    protected[play]
  18. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int

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

    Permalink
    Definition Classes
    Any
  21. def joinConcatI[AIn, X](implicit in: <:<[A, Iteratee[E, AIn]], p: (E) ⇒ TraversableLike[X, E], bf: CanBuildFrom[E, X, E]): Iteratee[E, AIn]

    Permalink
  22. def joinI[AIn](implicit in: <:<[A, Iteratee[_, AIn]]): Iteratee[E, AIn]

    Permalink
  23. def map[B](f: (A) ⇒ B)(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    Uses the provided function to transform the Iteratee's computed result when the Iteratee is done.

    Uses the provided function to transform the Iteratee's computed result when the Iteratee is done.

    f

    a function for transforming the computed result

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread.

  24. def mapM[B](f: (A) ⇒ Future[B])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    Like map but allows the map function to execute asynchronously.

    Like map but allows the map function to execute asynchronously.

    This is particularly useful if you want to do blocking operations, so that you can ensure that those operations execute in the right execution context, rather than the iteratee execution context, which would potentially block all other iteratee operations.

    f

    a function for transforming the computed result

    ec

    The context to execute the supplied function with. The context is prepared on the calling thread.

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

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

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

    Permalink
    Definition Classes
    AnyRef
  28. def pureFlatFold[B, C](folder: (Step[E, A]) ⇒ Iteratee[B, C])(implicit ec: ExecutionContext): Iteratee[B, C]

    Permalink

    Like pureFold, except taking functions that return an Iteratee

    Like pureFold, except taking functions that return an Iteratee

    returns

    an Iteratee extracted by calling the appropriate provided function

  29. def pureFlatFoldNoEC[B, C](folder: (Step[E, A]) ⇒ Iteratee[B, C]): Iteratee[B, C]

    Permalink

    A version of pureFlatFold that runs folder in the current thread rather than in a supplied ExecutionContext, called in several places where we are sure the stack cannot overflow.

    A version of pureFlatFold that runs folder in the current thread rather than in a supplied ExecutionContext, called in several places where we are sure the stack cannot overflow. This method is designed to be overridden by StepIteratee, which can execute the folder function immediately.

    Attributes
    protected[play]
  30. def pureFold[B](folder: (Step[E, A]) ⇒ B)(implicit ec: ExecutionContext): Future[B]

    Permalink

    Like fold but taking functions returning pure values (not in promises)

    Like fold but taking functions returning pure values (not in promises)

    returns

    a scala.concurrent.Future of a value extracted by calling the appropriate provided function

  31. def pureFoldNoEC[B](folder: (Step[E, A]) ⇒ B): Future[B]

    Permalink

    A version of pureFold that runs folder in the current thread rather than in a supplied ExecutionContext, called in several places where we are sure the stack cannot overflow.

    A version of pureFold that runs folder in the current thread rather than in a supplied ExecutionContext, called in several places where we are sure the stack cannot overflow. This method is designed to be overridden by StepIteratee, which can execute the folder function immediately.

    Attributes
    protected[play]
  32. def recover[B >: A](pf: PartialFunction[Throwable, B])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    Creates a new Iteratee that will handle any matching exception the original Iteratee may contain.

    Creates a new Iteratee that will handle any matching exception the original Iteratee may contain. This lets you provide a fallback value in case your Iteratee ends up in an error state.

    Example:

    def it = Iteratee.map(i => 10 / i).recover { case t: Throwable =>
      Logger.error("Must have divided by zero!", t)
      Integer.MAX_VALUE
    }
    
    Enumerator(5).run(it) // => 2
    Enumerator(0).run(it) // => returns Integer.MAX_VALUE and logs "Must have divied by zero!"
  33. def recoverM[B >: A](pf: PartialFunction[Throwable, Future[B]])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    A version of recover that allows the partial function to return a Future[B] instead of B.

  34. def recoverWith[B >: A](pf: PartialFunction[Throwable, Iteratee[E, B]])(implicit ec: ExecutionContext): Iteratee[E, B]

    Permalink

    A version of recover that allows the partial function to return an Iteratee[E, B] instead of B.

  35. def run: Future[A]

    Permalink

    Extracts the computed result of the Iteratee pushing an Input.EOF if necessary Extracts the computed result of the Iteratee, pushing an Input.EOF first if the Iteratee is in the play.api.libs.iteratee.Cont state.

    Extracts the computed result of the Iteratee pushing an Input.EOF if necessary Extracts the computed result of the Iteratee, pushing an Input.EOF first if the Iteratee is in the play.api.libs.iteratee.Cont state. In case of error, an exception may be thrown synchronously or may be used to complete the returned Promise; this indeterminate behavior is inherited from fold().

    returns

    a scala.concurrent.Future of the eventually computed result

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

    Permalink
    Definition Classes
    AnyRef
  37. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  38. def unflatten: Future[Step[E, A]]

    Permalink

    Converts the Iteratee into a Promise containing its state.

  39. final def wait(): Unit

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped