Legend:
Library
Module
Module type
Parameter
Class
Class type
Byte 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.
| Read_source_bufferof't->(Cstruct.t list-> int)-> unit
(*
If a source offers Read_source_buffer rsb then the user can call rsb t 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.
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.
Closing
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.