# Residency

> USearch for Zig

Where the payload lives is the constructor's name, as in the C lifecycle verbs, so a residency an index lacks has no constructor to call.
Each names the hardware its shards are placed across, one shard per memory domain, device or path, and an empty slice derives one from the machine.

```zig
// One graph per socket.
var in_memory = try usearch.DenseIndex.initRam(.{ .dimensions = 768 }, &.{ 0, 1 });
// Sharded across the devices, never replicated.
var on_device = try usearch.DenseIndex.initVram(.{ .dimensions = 768 }, &.{ 0, 1 });
// Served in place, read-only, and sized past RAM.
var on_disk = try usearch.DenseIndex.viewNvme("index.safegraphs.json", .{
    .executor = nvme_executor,
    .paths = &.{.of("/mnt/nvme0")},
});
```

An NVMe index is never initialized, only viewed in place, and it is read-only, so every mutating verb on it fails with `Error.ReadOnly`.
Until NVMe checkpoints carry keys, `viewNvme` answers `Error.Unsupported`.

`const usearch = @import("usearch");`

`const Residency = @import("usearch").Residency;`

## DenseReserve

One [`DenseIndex.reserve`](https://www.unum.cloud/docs/usearch/zig/metrics.md#reserve), as a [`Deferred`](https://www.unum.cloud/docs/usearch/zig/executors.md#Deferred) holds it.

```zig
pub const DenseReserve = struct
```

- `capacity` `usize`
- `outcome` `Outcome`

## DenseClear

One [`DenseIndex.clear`](https://www.unum.cloud/docs/usearch/zig/metrics.md#clear), as a [`Deferred`](https://www.unum.cloud/docs/usearch/zig/executors.md#Deferred) holds it.

```zig
pub const DenseClear = struct
```

- `outcome` `Outcome`

## Residency

Where an index's payload lives and which engine traverses it - the vocabulary the lifecycle verbs spell in their names, as [`DenseIndex.initVram`](https://www.unum.cloud/docs/usearch/zig/metrics.md#initVram) does.

```zig
pub const Residency = enum(c_int)
```

Kept for its name table.

- `ram` = `1`: Volatile-memory index traversed by CPU threads.
- `vram` = `2`: Accelerator-memory index traversed by GPU warps.
- `nvme` = `3`: Persisted index traversed through pluggable I/O engines.

## name

The canonical spelling, as `.ram` spells "ram".

```zig
pub fn name(self: Residency) [:0]const u8
```

Calls `usearch_residency_name`.

## fromName

Reads a spelling back, or null when no residency spells it.

```zig
pub fn fromName(text: []const u8) ?Residency
```

Calls `usearch_residency_from_name`.

