public int encode()
    {
        Verify.notNull(ir, "ir");

        write(buffer, encodeFrame());

        encodeTokenList(ir.headerStructure().tokens());

        ir.messages().forEach(this::encodeTokenList);

        return totalLength;
    }
Encode the provided {@link Ir} and return the length in bytes encoded.

@return encode the provided {@link Ir} and return the length in bytes encoded.
sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/IrEncoder.java