walpack library

High-performance, crash-safe, single-file binary container with chunked snapshot storage and an append-only CRC32-C Write-Ahead Log (WAL).

Classes

BinaryWriterPool
Object pool for reusing BinaryWriter instances to reduce GC pressure.
ChunkCodec
Abstraction for compressing and decompressing chunk and operation payloads.
ChunkIndexData
Optional secondary index attributes attached to a single chunk commit.
ChunkMeta
Immutable index metadata describing a live chunk stored in either the Base Snapshot or the WAL tail.
CodecRegistry
Fixed-time (O(1)) lookup table of registered ChunkCodecs keyed by byte ID.
CommitBuilder
Builder passed to WalPack.commit() for queueing atomic chunk puts, chunk deletions, and WAL operation deltas within a single transaction frame.
CommitCommitted
Returned when the transaction was atomically persisted into the WAL tail.
CommitConflict
Returned when expectedSeq did not match the latest sequence on storage due to a concurrent writer or compaction.
CommitNoOp
Returned when a commit builder queued no puts, deletes, or ops.
CommitResult
Outcome returned by WalPack.commit().
CompactBuilder
Builder passed to WalPack.compact(rewrite: ...) to override or prune chunks atomically while rebuilding the Copy-on-Write Base Snapshot.
CompactionPolicy
Controls when WalPack automatically triggers Copy-on-Write compaction.
ContentHash
Compact 64-bit content fingerprint pairing CRC32-C (lo) and XXH32 (hi).
FastCopyStorageBackend
Optional high-throughput copy capability implemented by backends (such as IoStorageBackend and MemoryStorageBackend) that can copy raw ranges into another StorageBackend using a single reusable buffer.
FaultInjectionBackend
Delegating StorageBackend wrapper that injects partial writes, mid-write crashes, and compaction swap failures for deterministic crash-safety tests.
GenerationAwareLockStrategy
Optional LockStrategy capability that persists the container compaction generation inside the lock descriptor itself so peers avoid reopening the data file on every commit or sync() check.
LockStrategy
Inter-process / inter-handle concurrency locking abstraction.
Lz4BlockCodec
Pure-Dart LZ4 block compressor and decompressor implementing ChunkCodec.
MemoryStorageBackend
Fast, pure-Dart in-memory StorageBackend backed by a growable Uint8List.
NoLockStrategy
No-op LockStrategy for single-process, in-memory, or read-only containers.
NoneChunkCodec
Identity codec (codecIdNone) that returns views directly without copying.
StorageBackend
Random-access I/O abstraction underlying WalPack.
SyncAppended
Returned when external appends were incrementally applied from the WAL tail without reloading the snapshot.
SyncCompacted
Returned when an external process replaced the container via compaction, causing this handle to reload the new Base Snapshot cleanly.
SyncResult
Outcome returned by WalPack.sync().
SyncUpToDate
Returned when the container handle is already up to date with storage.
TransientHandleStorageBackend
Optional capability for backends that re-resolve their storage location on every operation instead of pinning one open descriptor (for example the Windows file backend, which closes its handle between calls).
WalFrame
Parsed summary of a single verified WAL CommitFrame.
WalOp
A decoded WAL operation record with its sequence number and uncompressed payload.
WalOpMeta
Metadata index entry for an operation stored inside a WAL WalFrame.
WalPack
High-performance, crash-safe, single-file binary container combining an immutable chunked snapshot with an append-only CRC32-C Write-Ahead Log (WAL).
WalPackLimits
Defensive bounds enforced while encoding, scanning, and decoding containers to protect against malformed or adversarial inputs causing excessive memory allocations.
WalPackOptions
Configuration options for opening and operating a WalPack container.
WalPackStats
Live storage and sequence statistics for an open WalPack container.
WalPackVerification
Result of a full structural and checksum verification pass via verifyIntegrity().

Extension Types

BinaryReader
A high-performance binary reader for decoding data from a byte buffer.
BinaryWriter
A high-performance binary writer for encoding data into a byte buffer.

Extensions

BinaryReaderBytesString on BinaryReader
Byte array and string reading methods for BinaryReader.
BinaryReaderCore on BinaryReader
Core properties, operators, and lifecycle methods for BinaryReader.
BinaryReaderNumeric on BinaryReader
Fixed-width numeric reading methods for BinaryReader.
BinaryReaderPosition on BinaryReader
Position management methods for BinaryReader.
BinaryReaderRandomAccess on BinaryReader
Random access read methods for BinaryReader.
BinaryReaderVarInt on BinaryReader
Variable-length integer reading methods for BinaryReader.
BinaryWriterBytesString on BinaryWriter
Byte array and string writing methods for BinaryWriter.
BinaryWriterCore on BinaryWriter
Core properties, operators, and lifecycle methods for BinaryWriter.
BinaryWriterNumeric on BinaryWriter
Fixed-width numeric writing methods for BinaryWriter.
BinaryWriterPosition on BinaryWriter
Position management methods for BinaryWriter.
BinaryWriterScatterGather on BinaryWriter
Scatter-gather (zero-copy) output methods for BinaryWriter.
BinaryWriterVarInt on BinaryWriter
Variable-length integer writing methods for BinaryWriter.

Constants

chunkKindBlob → const int
Chunk kind for raw binary assets/blobs (e.g. images, fonts).
chunkKindData → const int
Default chunk kind for structured/typed domain data.
codecIdCustomMin → const int
First user-defined custom codec identifier (128..255).
codecIdLz4 → const int
Codec identifier for LZ4 block payloads (2, pure Dart).
codecIdNone → const int
Codec identifier for uncompressed payloads (0).
codecIdZlib → const int
Codec identifier for ZLib/Deflate payloads (1, native IO platforms).
crc32cInitial → const int
Initial running CRC32-C accumulator value (pre-inversion).
walPackFormatVersion → const int
Current binary format version (1).

Functions

crc32c(Uint8List data, [int start = 0, int? end]) → int
Computes the CRC32-C (Castagnoli) checksum of data[start .. end].
crc32cCombine(int crc1, int crc2, int len2) → int
Algebraically combines two finalized CRC32-C digests: given crc1 = crc32c(chunk1) and crc2 = crc32c(chunk2), returns crc32c(chunk1 + chunk2) in O(log(len2)) GF(2) steps without re-scanning.
crc32cFinalize(int crc) → int
Finalizes a running CRC32-C accumulator into an unsigned 32-bit digest.
crc32cUpdate(int crc, Uint8List data, [int start = 0, int? end]) → int
Updates an incremental CRC32-C crc accumulator over data[start .. end].
xxh32(Uint8List data, {int start = 0, int? end, int seed = 0}) → int
Computes the 32-bit XXH32 digest of data[start .. end] with seed.

Typedefs

LiveKeyRangeLookup = List<String> Function({String? end, bool includeEnd, bool includeStart, String? start})
Returns live committed keys within a range, in sorted order.

Exceptions / Errors

InjectedFaultException
Exception thrown intentionally by FaultInjectionBackend to simulate crashes or I/O failures mid-operation.
WalPackAppIdMismatchException
Thrown when the container's 4-byte application identifier does not match the caller's expectedAppId.
WalPackClosedException
Thrown when an operation is attempted on a closed WalPack instance.
WalPackCodecException
Thrown when a chunk codec is missing or compressed data cannot be decoded.
WalPackConflictException
Thrown by WalPack.commitWithRetry when every attempt hit an optimistic concurrency conflict.
WalPackCorruptException
Thrown when file headers, TOC entries, WAL frames, or chunk checksums fail validation and indicate binary corruption.
WalPackException
Base exception for all runtime failures thrown by walpack (storage, format, locks, codecs, conflicts).
WalPackLockException
Thrown when an underlying storage or file lock cannot be acquired (including a lock timeout) or fails.
WalPackNotFoundException
Thrown when opening an existing container that does not exist and createIfMissing is false.
WalPackReadOnlyException
Thrown when a mutating operation is attempted on a read-only WalPack instance.
WalPackUnsupportedVersionException
Thrown when the file's format version is newer or unsupported by this version of walpack.