BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Swallow · Verify a record table before interpreting a byte offset

Validate an exported payload's declared spans and checksum, then locate a byte.

Verify a record table before interpreting a byte offset

A valid byte offset can point into the wrong serialized record if lengths have drifted. Verify the table and payload before interpreting the offset. The payload bytes 65 and 66 yield checksum 12976260. Offset 1 is the first byte of the second record.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-swallow.git
cd blyx-swallow
blyxc native-run project.blyx -- "1,1" "65,66" 1 12976260

API and return values

Returns [checksum matches, actual Adler-32, record index, in-record offset]. The sum of payload lengths must equal the byte count. Use a verified cryptographic signature when authenticity is required. Invalid input returns an empty vector.

ArgumentAccepted input
lengthsVector of: nonnegative exact integer
payloadVector of: whole byte in [0,255]
offsetnonnegative exact integer
checksumnonnegative exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
1
12976260
1
0
Open in the full playground →

Practice

Change lengths = [1], payload = [0], offset = 0.0, checksum = 0.0. Predict the result, then run the program.

Hint

Returns [checksum matches, actual Adler-32, record index, in-record offset]. The sum of payload lengths must equal the byte count. Use a verified cryptographic signature when authenticity is required.

Worked solution

The result vector is [0, 65537, 0, 0]. Compare its fields with the return layout in the API section.

Find

    let lengths = [1, 1];

Replace with

    let lengths = [1];

Find

    let payload = [65, 66];

Replace with

    let payload = [0];

Find

    let offset = 1.0;

Replace with

    let offset = 0.0;

Find

    let checksum = 12976260.0;

Replace with

    let checksum = 0.0;

Output after the change

0
65537
0
0