Skip to main content

CompactBinary

Derive Macro CompactBinary 

Source
#[derive(CompactBinary)]
{
    // Attributes available to this derive:
    #[njson]
}
Expand description

Derives rustbinary::compact::CompactEncode and rustbinary::compact::CompactDecode — the schema-guided compact binary profile.

Struct fields encode in declaration order with no field names; enums write only a compact variant discriminant; containers are length-prefixed. The generated codec bypasses the generic nextjson event path entirely, so the hot loop carries no type tags, no field-name handling and no dynamic dispatch. #[njson(borrow)] is accepted for nextjson compatibility and is otherwise ignored: borrowing follows the field type, so &'a str and &'a [u8] fields decode as zero-copy references into the input when 'de: 'a holds. Unions are rejected.