Atom

binary.size()

Measures a byte span or layout size.

Signature

binary.size(value_or_descriptor)

Parameters

Packed value, supported scalar descriptor, layout dictionary or frozen layout.

Returns

Byte count as i64 or u64.

Behavior

For packed arrays, counts all bytes in the selected span.

Errors

Unsupported layout or invalid packed view.

Example

Atom
use binary
assert(binary.size(create(u16, 3)) == 6)

Ask how much room a layout takes

Pass a descriptor to calculate its byte size.

Atom
use binary
print(binary.size(u32))
Output
4

An unsigned 32-bit value occupies four bytes.

Measure populated packed storage

Pass an existing buffer to measure its bytes.

Atom
use binary
bytes = create(u8, 5)
print(binary.size(bytes))
Output
5

The five unsigned bytes take five bytes in memory.