play.api.libs.iteratee

Iteratee

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
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

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

    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: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

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

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

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

    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

  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. 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]

    Like fold1, except flattens the result with Iteratee.

    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.

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

    Like fold, except flattens the result with Iteratee.

    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.

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

    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.

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

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

    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.

  17. 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]

    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.

  18. 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]

    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

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

    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 ImmediateIteratee, which can execute the folder function immediately.

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

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

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

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

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

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

    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.

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

    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.

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

    Definition Classes
    AnyRef
  28. final def notify(): Unit

    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit

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

    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

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

    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 ImmediateIteratee, which can execute the folder function immediately.

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

    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

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

    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 ImmediateIteratee, which can execute the folder function immediately.

    Attributes
    protected[play]
  34. def run: Future[A]

    Extracts the computed result of the Iteratee pushing an Input.

    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

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

    Definition Classes
    AnyRef
  36. def toString(): String

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

    Converts the Iteratee into a Promise containing its state.

  38. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

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

    Annotations
    @deprecated
    Deprecated

    (Since version 2.2.0) use Iteratee.map instead

Inherited from AnyRef

Inherited from Any

Ungrouped