scanPrefix
An ordered walk over every document whose key begins with prefix.
store.scanPrefix(Key.of("receipt/")).use { cursor ->
while (cursor.next()) println(cursor.key)
}This exists because the range spelling of it does not work, and fails silently. [from, to] is inclusive at both ends, and a prefix range's upper end is inherently exclusive: the prefix with its last byte raised is one key too generous, so scanning [receipt/, receipt0] returns receipt0 — a key in a neighbouring namespace. There is no inclusive bound to reach for instead, because keys have no maximum length and so no greatest key carries a given prefix. Key.startsWith carries the full argument; Key.successor carries the other way the arithmetic goes wrong.
An empty prefix matches every key, which makes this the same walk as scan with no bounds rather than a special case to guard.
A separate name rather than a prefix parameter on scan, deliberately: as an overload, scan(k) on an existing caller would start resolving to the prefix form — Key being more specific than Key? — and silently mean something else.