Skip to main content

Module igbinary

Module igbinary 

Source
Expand description

igbinary_serialize and igbinary_unserialize, byte-identical to the igbinary extension (3.2, format version 2, igbinary.compact_strings=On) of the PHP image. Appwrite’s cache and queue payloads use it.

PHPRust
igbinary_serialize($v)serialize
igbinary_unserialize($s)unserialize (strings share the input buffer)
its warnings (igbinary_unserialize_*: ...)Error::Invalid

The format: a 4-byte version header (00 00 00 02), then one value. Integers take the smallest of 1, 2, 4 or 8 bytes with the sign in the type; floats are IEEE 754 big-endian; every non-empty string (values, keys, class names) is written once and referenced by its index after that; arrays and objects are a count and key/value pairs; containers get a reference id in pre-order for back-references.

Identity: PHP writes a back-reference when the same array or object instance appears twice, which a Value (no identity) cannot know. The engine shares one immutable empty array ([] literals, json_decode, unserialize, igbinary_unserialize), so serialize writes every empty array after the first as a back-reference to it, as PHP does for such data. Back-references PHP wrote for other shared instances or PHP references read as copies, and are written in full again. Objects of other classes (__PHP_Incomplete_Class in PHP), recursive structures and nesting deeper than MAX_DEPTH are Error::Unsupported.

Enums§

Error
Why igbinary_unserialize() failed.

Constants§

MAX_DEPTH
Nesting deeper than this is refused when reading (PHP recurses without a limit and exhausts its stack eventually).

Functions§

serialize
igbinary_serialize($value).
unserialize
igbinary_unserialize($data). Strings longer than an inline string share input’s buffer.