Hcs.Stream.Async
hcs · API reference
Asynchronous Stream (Eio)
Streams that integrate with Eio's structured concurrency.
type 'a t = unit -> 'a optionAn asynchronous stream that can be pulled from
Producers
val empty : 'a tval singleton : 'a -> 'a tval of_list : 'a list -> 'a tval of_seq : 'a Seq.t -> 'a tval of_flow :
?buf_size:int ->
[> Eio.Flow.source_ty ] Eio.Flow.source ->
Cstruct.t tCreate a stream from an Eio flow (reads until EOF)
val of_file :
?buf_size:int ->
fs:[> Eio.Fs.dir_ty ] Eio.Fs.dir ->
Eio.Fs.path ->
Cstruct.t tCreate a stream that reads a file in chunks
Transformers
val map : ('a -> 'b) -> 'a t -> 'b tval filter : ('a -> bool) -> 'a t -> 'a tval filter_map : ('a -> 'b option) -> 'a t -> 'b tval take : int -> 'a t -> 'a tConsumers
val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'bFold over the stream
val iter : ('a -> 'b) -> 'a t -> unitIterate over the stream
val drain : 'a t -> unitDrain the stream
val to_list : 'a t -> 'a listCollect into a list
val to_flow : [> Eio.Flow.sink_ty ] Eio.Flow.sink -> Cstruct.t t -> unitWrite stream to an Eio flow
Cstruct-specific operations
val cstructs_to_string : Cstruct.t t -> stringConcatenate a stream of Cstructs into a single string
val cstructs_to_cstruct : Cstruct.t t -> Cstruct.tRead entire stream into a Cstruct