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]): Future[B]

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

    Computes a promised value B from the state of the Iteratee. Note that the state of the Iteratee may be computed asynchronously, so the folder function may run asynchronously in another thread, but is not guaranteed to do so. Exceptions thrown by the folder function may be stored in the returned Promise or may be thrown from fold().

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

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()
  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]]): Iteratee[B, C]

  13. def flatMap[B](f: (A) ⇒ Iteratee[E, B]): 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

  14. def flatMapInput[B](f: (Step[E, A]) ⇒ Iteratee[E, B]): Iteratee[E, B]

  15. def flatMapM[B](f: (A) ⇒ Future[Iteratee[E, B]]): 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.

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

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

  17. def fold1[B](done: (A, Input[E]) ⇒ Future[B], cont: ((Input[E]) ⇒ Iteratee[E, A]) ⇒ Future[B], error: (String, Input[E]) ⇒ Future[B]): 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

    returns

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

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

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

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

    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]

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

  23. def map[B](f: (A) ⇒ B): 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 tranforming the computed result

  24. def mapDone[B](f: (A) ⇒ B): Iteratee[E, B]

  25. def mapM[B](f: (A) ⇒ Future[B]): 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.

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

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

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

    Definition Classes
    AnyRef
  29. def pureFlatFold[B, C](folder: (Step[E, A]) ⇒ Iteratee[B, C]): 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

  30. def pureFold[B](folder: (Step[E, A]) ⇒ B): 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

  31. 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

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

    Definition Classes
    AnyRef
  33. def toString(): String

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

    Converts the Iteratee into a Promise containing its state.

  35. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped