package bytesrw

  1. Overview
  2. Docs
Composable byte stream readers and writers for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

bytesrw-0.2.0.tbz
sha512=e3f07dbd808e152cd4b2ea5c2fa3863d4b72f7f97cfa3cd7493a3725c84f39d882042388ee47c9d6acfd30a650c21db429c8264db3d7466cad6e580308b5a2d2

doc/bytesrw/Bytesrw/Bytes/Stream/index.html

Module Bytes.StreamSource

Byte streams.

Byte streams are sequences of non-empty byte slices ended by a single Slice.eod slice. They have no concrete incarnation, they are observed by Bytes.Readers and Bytes.Writers.

See the quick start and read more about streams in the tutorial.

Positions

Sourcetype pos = int

The type for stream positions.

The position of a stream is the zero-based byte index of the next byte to read or write. It can also be seen as the count of bytes read or written by a stream reader or writer.

Formats

Sourcetype format = string

The type for stream formats. An identifier for the format of read or written bytes. Favour mime types or lowercased file extensions without the dot.

Errors

Read more about errors in the tutorial.

Sourcetype error = ..

The type for stream errors. Stream formats add their own cases to this type. See an example.

Sourcetype error_context

The type for error contexts.

Sourceexception Error of error * error_context

The exception raised by streams reader, writers and their creation functions.

Sourceval error_message : (error * error_context) -> string

error_message e turns error e into an error message for humans.

Sourceval error_to_result : (error * error_context) -> ('a, string) result

error_to_result e is Result.Error (error_message e).

Sourcetype 'e format_error

The type for describing errors of type 'e for a stream format.

Sourceval make_format_error : format:format -> case:('e -> error) -> message:(error -> string) -> 'e format_error

make_format_error ~format ~case ~message describes the type of error for format format:

  • format identifies the stream format.
  • case is the function that injects the type into error.
  • message is a function that must stringify the results of case.

See an example.

Sourceval error : 'e format_error -> ?context:[ `R | `W ] -> 'e -> 'a

error fmt e errors with e for a stream fmt by raising an Error exception.

Limits

Sourcetype error +=
  1. | Limit of int
    (*

    The inclusive byte count limit.

    *)

The type for stream limits errors.

Sourceval limit_error : int format_error

limit_error is a stream limit error.

OCaml

Innovation. Community. Security.