Page
Library
Module
Module type
Parameter
Class
Class type
Source
Flux.SourceSourceunfold seed next is a finite source created from a seed state and a function that produces elements and an updated state.
seq items is a source with all elements from the items sequence.
array items is a source with all elements from the items array.
string str is a source with all characters from the str string.
bqueue ?stop q is a source with all iterms from the q bounded-queue.
The user can choose how to dispose the given bounded-queue q:
`Ignore does nothing`Halt Bqueue.halt the given bounded-queue q`Close Bqueue.close the given bounded-queue qNOTE: `Halt a bounded-queue created with Bqueue.with_close also closes the given bounded-queue.
file ~filename len reads at most len bytes of the file filename until the end.
in_channel ic reads strings from the given in_channel ic. If the given ic is not stdin and ?close is true (by default), dispose closes it properly.
NOTE: Instead ofapplying the transformation functions at the source, consider using Stream.from or defining your computation as a flow to make it reusable.
A source with all elements transformed with a mapping function.
each fn src applies an effectful function fn to all elements in src.
next src is Some (x, rest) where x is the first element of src and rest is src without x; or None, if src is empty.
NOTE: If rest is produced, it is required to either consume it or manually dispose its resources. Not doing so might lead to resource leaks.
dispose src forces the termination of the source data. This function is useful in situations when a leftover source is produced in Stream.run.
NOTE: If the source is not already initialized, calling this function will first initialize its state before it is terminated.
resource ~finally pull value creates a new resource from a pull function and an initial value. resource uses Miou's ownership mechanism so that if the task consuming the resource is cancelled, the resource is properly released (and finally is executed).
This also requires the user to dispose the source at the end of the task, otherwise Miou's rules will be violated.
NOTE: The resource passed to the pull function is physically the same as init.
Type of tasks which should fill a given bounded-queue.
with_task ?halt ~size producer returns a source that is linked to a task producer producing elements of type 'a. The transfer of elements between the task and the source consumer is limited in memory by size elements at a time.
The source is not effective and may potentially block if the shared queue is empty and an attempt is made to consume it (via next, for example). The shared queue is automatically closed/halted (depending on ?halt, defaults to false) as soon as the producer terminates.
For more details on the difference between halt and close, please refer to the Bqueue module.
with_formatter ?halt ~size producer is a specialisation of with_task with a Format.formatter. Everything written in the formatter is transmitted to the consumer.