copybook-codec
High-performance COBOL copybook codec for mainframe-style fixed and RDW records.
copybook-codec converts decoded/encoded records between COBOL binary formats (DISPLAY, COMP-3, COMP/BINARY) and JSON.
What it does
- Parse and validate copybook schema output from
copybook-core. - Decode fixed-length and variable-length (RDW) files into JSON records.
- Encode JSON back to binary COBOL layouts with strict or tolerant mode.
- Configure behavior through
DecodeOptions/EncodeOptions. - Handle common mainframe codepages (
CP037,CP273,CP500,CP1047,CP1140, ASCII).
Quick start
use parse_copybook;
use ;
let schema = parse_copybook?;
let options = new
.with_codepage
.with_json_number_mode;
let json = decode_record?;
println!;
Features
- Record streaming for large fixed-width files
- Deterministic conversions with controlled rounding/precision behavior
- Optional metrics and strict compatibility-policy checks
- Optional audit-related feature path for enterprise usage
- Edited PIC decode and encode support (E2/E3 phases)
- Field projection via
project_schema()for selective field decoding - Raw data capture modes (
RawMode::Record,RawMode::Field,RawMode::RecordRDW) - Scratch buffer optimization for hot-path performance (
decode_record_with_scratch)
Scratch buffer example
use parse_copybook;
use ;
use ScratchBuffers;
let schema = parse_copybook?;
let options = new
.with_codepage
.with_json_number_mode;
let mut scratch = new;
let json = decode_record_with_scratch?;
API docs
License
Licensed under AGPL-3.0-or-later. See LICENSE.