package bin

All checked builds pass
  1. Overview
  2. Docs
A DSL to describe binary formats

Install

dune-project
 Dependency

Authors

Maintainers

Sources

bstr-0.1.3.tbz
sha256=69b9b01c66005ac8492b79bd541c78c885cf26ba5b6542c2b9898b60810f127c
sha512=d10e823bc4f974789152b0d86473078ca52520836a99ed6559214e95e2ead88b440898c1e4dacdc4bf07756d5afca615b406208e7d9524d9594c6011ce8e8d26

doc/bin/Bin/Off/index.html

Module Bin.OffSource

Sourcetype 'w t = private int

An index into a byte sequence, counted in bytes and never negative. The parameter 'w records what the index is counted from.

Sourcetype abs

An absolute index, counted from the first byte of the buffer. It designates a byte on its own, so it is what one can read or write at. A cursor is of this kind.

Sourcetype rel

A relative index: a displacement, counted from somewhere else: in practice from the beginning of the value being decoded. Describing a format yields such displacements (the offset of a field within its record) long before any buffer exists, so they designate nothing by themselves. They become usable once added to an absolute index, and the parameter is there to make sure that addition happens.

Sourceval zero : 'w t

zero is 0. It is both the first index of a buffer and the null displacement, hence its two possible kinds: it is the value to start a cursor with.

Sourceval at : abs t -> rel t -> abs t

at base delta is the absolute index which sits delta bytes after base. This is the only way to turn a displacement into an index one can read at.

Sourceval v : int -> abs t

v n is a new absolute offset.