Skip to main content

Envelope

Transport container with data compression and checksum validation

OffsetSizeNameDescription
04magic(ubyte[4]) MagicBytes = 0xDEADBEEF
44schema(uint) Container version (for future)
84level(CompressionLevel:uint) ZLIB level: none=0, zlib9=9
128datsize(ulong) Data block size
208datsum(ubyte[8]) Data block checksum
284hdrsum(ubyte[4]) Header (above 28 bytes) checksum

Data

OffsetSizeNameDescription
32...data(ubyte[]) Data block
tail(ubyte[]) Rest of incoming buffer after the end of envelope
errorstate(bool) Error state after incoming buffer parsed and validated
errors(string[]) Error list after incoming buffer parsed and validated

Methods

Constructor from buffer

Envelope(ubyte[] buf); - try to find first header, validate it, cut the tail and set error status

Constructor from scratch

Envelope(uint schema, uint level, ref ubyte[] data); - build envelope, compress data if needed and set checksums

Transport buffer exporter

toBuffer() - returns ubyte[] with whole envelope

Data extractor

toData() - returns ubyte[] with uncompressed data block