StorageNamespace class

Storage alignment utilities providing sector, block, page, and word calculations along with rounding and alignment checks.

Access via the storage namespace:

final size = ByteConverter.fromKiloBytes(512);
print(size.storage.sectors);        // Number of sectors
print(size.storage.isWholeSector);  // true if aligned to sector boundary
print(size.storage.roundToBlock()); // Round to block boundary

Constructors

StorageNamespace(double _bytes)
Creates a StorageNamespace for the given byte count.
const

Properties

blocks → int
Number of 4096-byte blocks (rounded up).
no setter
blockSlack → ByteConverter
Returns wasted bytes when aligning to block boundary.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isWholeBlock → bool
True if this value is exactly aligned to a block boundary (4096 B).
no setter
isWholePage → bool
True if this value is exactly aligned to a page boundary (4096 B).
no setter
isWholeSector → bool
True if this value is exactly aligned to a sector boundary (512 B).
no setter
isWholeWord → bool
True if this value is exactly aligned to a word boundary (8 B).
no setter
pages → int
Number of 4096-byte pages (rounded up).
no setter
pageSlack → ByteConverter
Returns wasted bytes when aligning to page boundary.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sectors → int
Number of 512-byte sectors (rounded up).
no setter
sectorSlack → ByteConverter
Returns wasted bytes when aligning to sector boundary.
no setter
words → int
Number of 8-byte words (rounded up).
no setter
wordSlack → ByteConverter
Returns wasted bytes when aligning to word boundary.
no setter

Methods

alignmentSlack(StorageProfile profile, {String? alignment, RoundingMode? rounding}) → ByteConverter
Calculates slack (unused bytes) after alignment.
alignTo(int boundarySize) → ByteConverter
Aligns to a custom boundary size.
isAligned(StorageProfile profile, {String? alignment}) → bool
Returns true when this value satisfies the requested profile alignment.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
roundToBlock() → ByteConverter
Rounds up to the next block boundary (4096 B).
roundToPage() → ByteConverter
Rounds up to the next page boundary (4096 B).
roundToProfile(StorageProfile profile, {String? alignment, RoundingMode? rounding}) → ByteConverter
Aligns this value to a StorageProfile bucket.
roundToSector() → ByteConverter
Rounds up to the next sector boundary (512 B).
roundToWord() → ByteConverter
Rounds up to the next word boundary (8 B).
toString() → String
A string representation of this object.
inherited

Operators

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