E1098: invalid serialization contract

View source

A serialize declaration describes a fixed frame over an existing pack (ADR-0064).

A serialize declaration describes a fixed frame over an existing pack (ADR-0064). It needs one version section of type u16, one payload section with a length above zero, and one checksum section that covers a non-empty range and does not overlap its own field. All sections must lie inside the pack and may not overlap each other. The source must be a pack with byte storage, and the names <name>_encode, _decode, _validate and _migrate must be free. The message ends with the reason, such as contract requires version, payload, and checksum sections or checksum field must not overlap its input range. The error points at the declaration.

Example

actus
pack Frame {
    erg storage: Array[u8, 24];
    layout little;
    fields {
        erg version: u16 at 0;
        erg bytes: Array[u8, 18] at 16;
        erg sum: u32 at 160;
    }
}

serialize Wire from Frame {
    layout little;
    version u16 at 0;
    payload bytes at 2 length 16;
}

verb main() {
}

Fix

Declare all three sections, inside the pack and without overlap.

actus
pack Frame {
    erg storage: Array[u8, 24];
    layout little;
    fields {
        erg version: u16 at 0;
        erg bytes: Array[u8, 18] at 16;
        erg sum: u32 at 160;
    }
}

serialize Wire from Frame {
    layout little;
    version u16 at 0;
    payload bytes at 2 length 16;
    checksum crc32 over 0 .. 18 at 18;
}

verb main() {
}

Run actus explain E1098 in your terminal to read this entry offline. Browse Ownership & types or all error codes.