# codixor/rs-mmap architecture

> Architecture diagram of the GitHub repository codixor/rs-mmap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codixor/rs-mmap
- Repository: https://github.com/codixor/rs-mmap

## Overview

rs-mmap is a Rust library for file snapshots and memory mappings, writable persistence, and optional typed records and system-level features. The principal workflow is a caller selecting a file range with MmapOptions, then receiving a stable mapped view when safe or a private snapshot otherwise; callers can also explicitly request trusted stable-file mappings. Writable snapshots support explicit write-back, while the optional record API adds checked fixed-layout values. Some modules are represented by their documented capabilities because their implementation was not sampled.

Main entry points: [`src/builder.rs`](https://github.com/codixor/rs-mmap/blob/main/src/builder.rs) (Mapping options), [`src/read_only_file.rs`](https://github.com/codixor/rs-mmap/blob/main/src/read_only_file.rs) (Read-only file source), [`src/slice.rs`](https://github.com/codixor/rs-mmap/blob/main/src/slice.rs) (Checked slices), [`src/record.rs`](https://github.com/codixor/rs-mmap/blob/main/src/record.rs) (Fixed-layout records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["File access"]
  node_options["Mapping options<br/>[builder.rs]"]
  node_file_source["Read-only file source<br/>[read_only_file.rs]"]
  node_trusted["Stable-file mapping<br/>[trusted.rs]"]
end

subgraph group_memory["Mapping and views"]
  node_mapping["Writable mappings<br/>[mapping.rs]"]
  node_slice["Checked slices<br/>[slice.rs]"]
  node_advice["Memory advice<br/>[advice.rs]"]
  node_errors["Mapping errors<br/>[error.rs]"]
end

subgraph group_records["Typed records"]
  node_typed_view["Typed views<br/>[view.rs]"]
  node_record["Fixed-layout records<br/>[record.rs]"]
  node_byte_field["Byte fields<br/>[byte_field.rs]"]
end

subgraph group_system["System features"]
  node_file_lock["Advisory locks<br/>[file_lock.rs]"]
  node_huge_pages["Huge-page allocation<br/>[huge_pages.rs]"]
  node_numa["NUMA queries<br/>[numa.rs]"]
end

node_caller(("Library caller"))

node_caller -->|"selects range"| node_options
node_options -->|"opens window"| node_file_source
node_file_source -->|"maps stable file"| node_trusted
node_options -->|"creates writable snapshot"| node_mapping
node_caller -->|"creates or opens"| node_record
node_record -->|"persists record"| node_mapping
node_caller -->|"requests byte range"| node_slice
node_slice -->|"validates typed data"| node_typed_view

click node_options "https://github.com/codixor/rs-mmap/blob/main/src/builder.rs"
click node_file_source "https://github.com/codixor/rs-mmap/blob/main/src/read_only_file.rs"
click node_trusted "https://github.com/codixor/rs-mmap/blob/main/src/trusted.rs"
click node_mapping "https://github.com/codixor/rs-mmap/blob/main/src/mapping.rs"
click node_slice "https://github.com/codixor/rs-mmap/blob/main/src/slice.rs"
click node_advice "https://github.com/codixor/rs-mmap/blob/main/src/advice.rs"
click node_typed_view "https://github.com/codixor/rs-mmap/blob/main/src/view.rs"
click node_record "https://github.com/codixor/rs-mmap/blob/main/src/record.rs"
click node_byte_field "https://github.com/codixor/rs-mmap/blob/main/src/byte_field.rs"
click node_file_lock "https://github.com/codixor/rs-mmap/blob/main/src/file_lock.rs"
click node_huge_pages "https://github.com/codixor/rs-mmap/blob/main/src/huge_pages.rs"
click node_numa "https://github.com/codixor/rs-mmap/blob/main/src/numa.rs"
click node_errors "https://github.com/codixor/rs-mmap/blob/main/src/error.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_options,node_file_source,node_trusted toneBlue
class node_mapping,node_slice,node_advice,node_errors toneAmber
class node_typed_view,node_record,node_byte_field toneMint
class node_file_lock,node_huge_pages,node_numa toneRose
class node_caller toneIndigo
```

## Components

### File access

- [Mapping options](https://github.com/codixor/rs-mmap/blob/main/src/builder.rs): `src/builder.rs`
- [Read-only file source](https://github.com/codixor/rs-mmap/blob/main/src/read_only_file.rs): `src/read_only_file.rs`
- [Stable-file mapping](https://github.com/codixor/rs-mmap/blob/main/src/trusted.rs): `src/trusted.rs`

### Mapping and views

- [Writable mappings](https://github.com/codixor/rs-mmap/blob/main/src/mapping.rs): `src/mapping.rs`
- [Checked slices](https://github.com/codixor/rs-mmap/blob/main/src/slice.rs): `src/slice.rs`
- [Memory advice](https://github.com/codixor/rs-mmap/blob/main/src/advice.rs): `src/advice.rs`
- [Mapping errors](https://github.com/codixor/rs-mmap/blob/main/src/error.rs): `src/error.rs`

### Typed records

- [Typed views](https://github.com/codixor/rs-mmap/blob/main/src/view.rs): `src/view.rs`
- [Fixed-layout records](https://github.com/codixor/rs-mmap/blob/main/src/record.rs): `src/record.rs`
- [Byte fields](https://github.com/codixor/rs-mmap/blob/main/src/byte_field.rs): `src/byte_field.rs`

### System features

- [Advisory locks](https://github.com/codixor/rs-mmap/blob/main/src/file_lock.rs): `src/file_lock.rs`
- [Huge-page allocation](https://github.com/codixor/rs-mmap/blob/main/src/huge_pages.rs): `src/huge_pages.rs`
- [NUMA queries](https://github.com/codixor/rs-mmap/blob/main/src/numa.rs): `src/numa.rs`

### Other components

- **Library caller**

## Connections

- Library caller → Mapping options: selects range (evidence: `README.md`)
- Mapping options → Read-only file source: opens window (evidence: `src/builder.rs`)
- Read-only file source → Stable-file mapping: maps stable file (evidence: `src/read_only_file.rs`)
- Mapping options → Writable mappings: creates writable snapshot (evidence: `src/builder.rs`)
- Library caller → Fixed-layout records: creates or opens (evidence: `README.md`)
- Fixed-layout records → Writable mappings: persists record (evidence: `src/record.rs`)
- Library caller → Checked slices: requests byte range (evidence: `README.md`)
- Checked slices → Typed views: validates typed data (evidence: `src/slice.rs`)
