Module Eio_mock.FlowSource

Mock Eio.Flow sources and sinks.

Sourcetype ty = [ `Generic | `Mock ] Eio.Net.stream_socket_ty
Sourceval make : ?pp:string Fmt.t -> string -> t

make label is a mock Eio flow. It can be used as a source, sink, or two-way flow.

  • parameter pp

    Printer to use to display the data.

Sourceval on_read : t -> string Handler.actions -> unit

on_read t actions configures the values to return from the mock's read function.

Sourceval on_copy_bytes : t -> int Handler.actions -> unit

on_copy_bytes t actions limits the number of bytes accepted by each write operation.

Sourceval trace_reads : string -> _ Eio.Flow.source -> Eio.Flow.source_ty Eio.Std.r

trace_reads label s wraps s to make a new source that traces reads (including via Read_source_buffer).

  • since 1.7
Sourceval limit_reads : int list -> _ Eio.Flow.source -> Eio.Flow.source_ty Eio.Std.r

limit_reads sizes s wraps s to make a new source that limits the buffers passed to single_read or to the Read_source_buffer callback to the given sizes. e.g. limit_reads [3; 2] s ensures that the first read will get no more than 3 bytes. Once sizes is exhausted, reads are unlimited.

  • since 1.7