package bin

  1. Overview
  2. Docs
A DSL to describe binary formats

Install

dune-project
 Dependency

Authors

Maintainers

Sources

bstr-0.1.1.tbz
sha256=e657cffda56910b14b98c76dd6e0382ea4bc5d0167e88391aba93196b016eee0
sha512=80dccae9308f57185a2c2fcfc63727043a5d0c7a0cf9b3687064882d64449404a51352d90160042f12f9bd3173aaf19ec715d1c796f4e808c0677ea9dbcb9ca8

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.