package ocsigenserver
Install
Dune Dependency
Authors
Maintainers
Sources
md5=acb09f06430cb8eefd83a849af6450af
sha512=f2c5111a02989572a19706ca5238d3740c4c06d97b0e1791ae0e06665666574ada94421d10edee636042984ab9df6357b4febbb4edc34b01e72619027b95bfec
doc/ocsigenserver.baselib/Ocsigen_stream/index.html
Module Ocsigen_stream
Streams are a means to read data block by block
A stream may be composed by several substreams. Thus a stream is either something that contains the current buffer and a function to retrieve the following data, or a finished stream with possibly another stream following.
get the next step of a stream. Fails with Interrupted e
if reading the thread failed with exception e
, and with Cancelled
if the thread has been cancelled.
creates an empty step. The parameter is the following substream, if any.
Add a finalizer function. In the current version, finalizers must be called manually.
Finalize the stream. This function must be called explicitly after reading the stream, otherwise finalizers won't be called.
val cancel : 'a t -> unit Lwt.t
Cancel the stream, i.e. read the stream until the end, without decoding. Further tries to read on the stream will fail with exception Ocsigen_stream.Cancelled
val consume : 'a t -> unit Lwt.t
Consume without cancelling. Read the stream until the end, without decoding.
val string_of_stream : int -> string stream -> string Lwt.t
Creates a string from a stream. The first argument is the upper limit of the string length
stream_want s len
Returns a stream with at least len bytes in the buffer if possible
val current_buffer : string step -> string
Returns the value of the current buffer
Skips data. Raises Stream_too_small (Some size)
if the stream is too small, where size
is the size of the stream.
Cut the stream at the position given by a string delimiter
val of_file : string -> string t
returns a stream reading from a file. Do not forget to finalize the stream to close the file.
val of_string : string -> string t
returns a stream containing a string.
val of_lwt_stream : 'a Lwt_stream.t -> 'a t
Convert a Lwt_stream.t
to an Ocsigen_stream.t
.
val to_lwt_stream : ?is_empty:('a -> bool) -> 'a t -> 'a Lwt_stream.t
Convert an Ocsigen_stream.t
into a Lwt_stream.t
.
module StringStream : sig ... end