# Serialization

> The path extension picks the layout: a .safegraphs path is one monolith, and a .safegraphs.json path is a manifest cataloging many.

`#include <usearch/types.hpp>` 3.0.0-rc.1 · cabb6603

The path extension picks the layout: a `.safegraphs` path is one monolith, and a `.safegraphs.json` path is a manifest cataloging many.

```cpp
usearch_bytes_view_t const path = us::bytes_view("index.safegraphs");
us::status_t const saved = index.on(executor).save(path);
auto [loaded, loaded_status] = us::dense_index_t::load_ram({.path = path});
auto [gpu, gpu_status] = us::executor_t::for_vram({.vram = {.devices = devices, .devices_count = 1}});
auto [placed, placed_status] = us::dense_index_t::load_vram({.path = path, .vram = {.devices = devices, .devices_count = 1}}, gpu);
auto [viewed, viewed_status] = us::dense_index_t::view_ram({.path = path});        // read-only, served from the mapping
auto [metadata, metadata_status] = us::dense_index_t::metadata_read({.path = path}); // geometry without loading a shard
```

Checkpoints are residency-portable: one file materializes into RAM, uploads to a device, or opens in place on disk, decided by the constructor that reads it. The metadata carries only the four fields a checkpoint froze, so `values_per_key` and the placement stay yours to set in the load arguments. `view_ram` answers `status_code_t::unsupported_k` until RAM shards can serve a mapping in place. A stopped `save` leaves leftovers every reader rejects, which are yours to remove.

In-memory buffers hold single monoliths only, through `save_buffer`, `load_ram_buffer` or `load_vram_buffer`, and `metadata_read_buffer`.

```cpp
auto [arena, arena_status] = us::arena_t::make({.executor = executor.handle()});
auto [monolith, status] = index.on(executor).save_buffer(arena);
auto [restored, restored_status] = us::dense_index_t::load_ram_buffer({.buffer = monolith});
```

## API

### Functions

#### `bytes_view`

The bytes of `text` as a call takes a path, a name or a buffer, read only during the call.

[types.hpp:384 ↗](https://github.com/unum-cloud/USearch/blob/cabb660355b45ed0d6ade2dc86ca58be01d61e29/cpp/usearch/types.hpp#L384)

```cpp
usearch_bytes_view_t bytes_view(std::string_view text) noexcept;
```
