Rust · Platform Notes

Platform Notes

3.0.0-rc.1 · 4c3e5023

§ What This Binding Does Not Expose

These C entry points also take a deferred completion, but the crate calls them blocking, whatever receiver you hold:

  • The load_* family, view_nvme, metadata and metadata_buffer, with each load config’s executor choosing where it fans out.
  • clear, which runs on the calling thread under &mut DenseIndex.
  • Cursor and search-stream pulls, which run on the executor of the receiver that opened them, and open only from a blocking one.

init_ram, init_vram and view_ram block in C as well.

§ Design

  • A thin layer over the C ABI. Every name follows c/usearch/: a C verb usearch_dense_<verb> is a <verb> here, each module mirrors one header, a verb’s argument struct becomes its Dense*Config, and every wrapper’s documentation names the C symbol it calls. Enums mirror C enums, never strings.
  • The receiver chooses, the verb stays. &DenseIndex runs a verb on the calling thread, on(&executor) blocks on an executor, and deferred(&executor) submits it, all with the same arguments.
  • Deferred calls use the language’s own idioms. status polls through usearch_outcome_status, wait blocks through usearch_outcome_wait, and a Deferred is IntoFuture, so .await polls the status word, since the library has no wake-up.
  • No life of its own. The binding starts no threads and keeps no queues; releasing a Deferred rides Drop, which waits for the call first.
  • Arenas are lent and reused, never shared. Every output whose length scales with the call lands in an arena the caller passes; the result borrows it, so the borrow checker retires stale views at compile time.
  • Nothing costs anything until it is used. Blocking calls allocate no box, and an arena allocates only when a call writes into it.
  • Callers lend memory, never an allocator. No allocation callback crosses into the library: payload belongs to the index, placed by its constructor’s residency, and scratch belongs to the executor.
  • A deferred receiver refuses borrowed inputs at compile time. The Accepts bound admits only owned inputs, so a borrow the library would read after the verb returns never compiles.