OCaml Library Collection
/

Internal Representations

These types expose the internal INI representation for use by Init_bytesrw and other codec backends. Most users should use the high-level Section and Document modules instead.

INI Values

type ini_value = {
  1. raw : string;
    (*

    The raw value before interpolation (e.g., "%(base)s/data").

    *)
  2. interpolated : string;
    (*

    The value after interpolation (e.g., "/opt/app/data").

    *)
  3. meta : Meta.t;
    (*

    Source location and layout.

    *)
}

The type for decoded INI values. The raw field preserves the original text for round-tripping, while interpolated has variables expanded.

INI Sections

type ini_section = {
  1. name : string node;
    (*

    Section name with metadata (e.g., "server").

    *)
  2. options : (string node * ini_value) list;
    (*

    List of (option_name, value) pairs in file order.

    *)
  3. meta : Meta.t;
    (*

    Metadata for the section header line.

    *)
}

The type for decoded INI sections.

INI Documents

type ini_doc = {
  1. defaults : (string node * ini_value) list;
    (*

    Options from the DEFAULT section (available to all sections).

    *)
  2. sections : ini_section list;
    (*

    All non-DEFAULT sections in file order.

    *)
  3. meta : Meta.t;
    (*

    Document-level metadata.

    *)
}

The type for decoded INI documents.

Codec State

Internal state used by section and document codecs.

type 'a codec_result = ('a, Error.t) result

The type for codec results.

type 'a section_state = {
  1. decode : ini_section -> 'a codec_result;
  2. encode : 'a -> ini_section;
  3. known_options : string list;
  4. unknown_handler : [ `Skip | `Error | `Keep ];
}

Section codec state. The known_options list is used to validate that required options are present and to detect unknown options.

type 'a document_state = {
  1. decode : ini_doc -> 'a codec_result;
  2. encode : 'a -> ini_doc;
  3. known_sections : string list;
  4. unknown_handler : [ `Skip | `Error ];
}

Document codec state.