IoStorageBackend class final

Native dart:io StorageBackend built on RandomAccessFile.

Features:

  • Tracks the current file cursor (_knownPos) to skip redundant setPosition syscalls during sequential WAL appends and compaction.
  • Runs operations <= 256 KiB synchronously in IoMode.hybrid to avoid Dart VM IO thread-pool roundtrips while delegating large transfers and flush() cleanly.
  • Coalesces small adjacent write segments (<= 4 KiB) into a single syscall buffer while writing large borrowed payloads directly without copying.
  • Streams chunks during compaction via a reusable 512 KiB buffer (copyRangeTo).
  • Performs Copy-on-Write atomicReplace using a sibling temp file, explicit flush(), and OS rename().
Implemented types

Properties

hashCode → int
The hash code for this object.
no setterinherited
ioMode → IoMode
I/O mode controlling sync vs async execution thresholds.
final
keepHandleOpen → bool
Whether the OS RandomAccessFile descriptor stays open between calls.
final
path → String
Filesystem path of the container file.
final
readOnly → bool
Whether this backend was opened read-only.
final
reopensOnEachAccess → bool
Whether each operation re-opens the underlying storage location.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

atomicReplace(Future<void> buildTemp(StorageBackend temp)) → Future<void>
Atomically swaps the container's contents with a fresh backend built by buildTemp.
override
close() → Future<void>
Releases all resources held by this backend.
override
copyRangeTo({required int sourceOffset, required int length, required StorageBackend dest, required int destOffset}) → Future<void>
Streams length bytes starting at sourceOffset to dest at destOffset.
override
flush() → Future<void>
Flushes buffered OS writes to durable storage.
override
length() → Future<int>
Returns the current byte length of the container (0 if empty/new).
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readAt(int offset, int length) → Future<Uint8List>
Reads up to length bytes starting at byte offset.
override
reopen() → Future<void>
Re-opens the underlying storage descriptor after an external compaction replaced the file on disk.
override
toString() → String
A string representation of this object.
inherited
truncate(int newLength) → Future<void>
Resizes the container to newLength bytes (shrinking discards tail bytes).
override
writeSegmentsAt(int offset, List<Uint8List> segments) → Future<void>
Writes all segments sequentially starting at offset.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

open(String path, {required bool createIfMissing, required bool readOnly, IoMode ioMode = .hybrid, bool? keepHandleOpen}) → Future<IoStorageBackend>
Opens path as an IoStorageBackend.