Eio.FlowSourceByte streams.
Flows are used to represent byte streams, such as open files and network sockets. A source provides a stream of bytes. A sink consumes a stream. A two_way can do both.
To read structured data (e.g. a line at a time), wrap a source using Buf_read.
Sources can offer a list of ways to read them, in order of preference.
single_read src buf reads one or more bytes into buf.
It returns the number of bytes read (which may be less than the buffer size even if there is more data to be read). single_read src just makes a single call to src#read_into (and asserts that the result is in range).
read_exact instead if you want to fill buf completely.Buf_read.line to read complete lines.copy to stream data directly from a source to a sink.buf must not be zero-length.
read_exact src dst keeps reading into dst until it is full.
read_methods flow is a list of extra ways of reading from flow, with the preferred (most efficient) methods first.
If no method is suitable, read should be used as the fallback.
cstruct_source cs is a source that gives the bytes of cs.
type read_method += | Read_source_buffer of (Cstruct.t list -> int) -> unitIf a source offers Read_source_buffer rsb then the user can call rsb fn to borrow a view of the source's buffers. fn returns the number of bytes it consumed.
rsb will raise End_of_file if no more data will be produced. If no data is currently available, rsb will wait for some to become available before calling fn.
fn must not continue to use the buffers after it returns.
buffer_sink b is a sink that adds anything sent to it to b.
To collect data as a cstruct, use Buf_read instead.
type shutdown_command = [ | `ReceiveIndicate that no more reads will be done
*)| `SendIndicate that no more writes will be done
*)| `AllIndicate that no more reads or writes will be done
*) ]shutdown t cmd indicates that the caller has finished reading or writing t (depending on cmd).
This is useful in some protocols to indicate that you have finished sending the request, and that the remote peer should now send the response.
Flows are usually attached to switches and closed automatically when the switch finishes. However, it can be useful to close them sooner manually in some cases.
Alias of Generic.close.