Atom

binary.offset()

Reports a record field's byte offset.

Signature

binary.offset(value_or_descriptor, field)

Parameters

Packed value or record layout, and a field name.

Returns

Integer byte offset.

Behavior

Uses the layout's alignment and packing cap.

Errors

Unknown field or invalid layout.

Example

Atom
use binary
assert(binary.offset({a = u8, b = u8}, 'b') == 1)