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()
.
a function that will be called on the current state of the iteratee
the ExecutionContext to run folder within
the result returned when folder is called
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).
input being sent
Like fold1, except flattens the result with Iteratee.
Like fold1, except flattens the result with Iteratee.flatten.
The context to execute the supplied function with. The context is prepared on the calling thread.
Like fold, except flattens the result with Iteratee.
Like fold, except flattens the result with Iteratee.flatten.
The context to execute the supplied function with. The context is prepared on the calling thread.
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
a function for transforming the computed result into an Iteratee
The context to execute the supplied function with. The context is prepared on the calling thread.
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.
a function for transforming the computed result into an Iteratee
The context to execute the supplied function with. The context is prepared on the calling thread.
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.
a function for transforming the computed result into an Iteratee
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.
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
a function that will be called if the Iteratee is a Done
a function that will be called if the Iteratee is a Cont
a function that will be called if the Iteratee is an Error
The context to execute the supplied functions with. The context is prepared on the calling thread.
a scala.concurrent.Future of a value extracted by calling the appropriate provided function
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.
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.
a function for transforming the computed result
The context to execute the supplied function with. The context is prepared on the calling thread.
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.
a function for transforming the computed result
The context to execute the supplied function with. The context is prepared on the calling thread.
Like pureFold, except taking functions that return an Iteratee
Like pureFold, except taking functions that return an Iteratee
an Iteratee extracted by calling the appropriate provided function
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.
Like fold but taking functions returning pure values (not in promises)
Like fold but taking functions returning pure values (not in promises)
a scala.concurrent.Future of a value extracted by calling the appropriate provided function
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.
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!"
A version of recover
that allows the partial function to return a Future[B] instead of B.
A version of recover
that allows the partial function to return a Future[B] instead of B.
A version of recover
that allows the partial function to return an Iteratee[E, B] instead of B.
A version of recover
that allows the partial function to return an Iteratee[E, B] instead of B.
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().
a scala.concurrent.Future of the eventually computed result
Converts the Iteratee into a Promise containing its state.
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.
Input type
Result type of this Iteratee