# manishearth/triomphe architecture

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

- Interactive diagram: https://gitdiagram.com/manishearth/triomphe
- Repository: https://github.com/manishearth/triomphe

## Overview

Triomphe is a Rust shared-ownership pointer library: users choose Arc or a specialized representation, then use its ownership, borrowing, and conversion APIs. Arc is the core reference-counted owner; Header supports dynamically sized allocations, while UniqueArc, OffsetArc, ThinArc, and ArcUnion provide distinct ownership or layout variants. Optional arc-swap support adapts Arc and ThinArc to that crate’s reference-count interface. The map follows documented capabilities and excerpted calls; unsampled implementation details and unshown links are omitted.

Main entry points: [`src/arc.rs`](https://github.com/manishearth/triomphe/blob/master/src/arc.rs) (Arc), [`src/unique_arc.rs`](https://github.com/manishearth/triomphe/blob/master/src/unique_arc.rs) (UniqueArc), [`src/thin_arc.rs`](https://github.com/manishearth/triomphe/blob/master/src/thin_arc.rs) (ThinArc), [`src/arc_borrow.rs`](https://github.com/manishearth/triomphe/blob/master/src/arc_borrow.rs) (ArcBorrow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ownership["Shared ownership"]
  node_arc["Arc<br/>[arc.rs]"]
  node_unique["UniqueArc<br/>[unique_arc.rs]"]
end

subgraph group_representations["Pointer representations"]
  node_borrow["ArcBorrow<br/>[arc_borrow.rs]"]
  node_offset["OffsetArc<br/>[offset_arc.rs]"]
  node_thin["ThinArc<br/>[thin_arc.rs]"]
  node_union["ArcUnion<br/>[arc_union.rs]"]
end

subgraph group_support["Allocation and integration"]
  node_header["Header layouts<br/>[header.rs]"]
  node_iterator["Iterator adapter"]
  node_allocerror["Allocation error<br/>[alloc_error.rs]"]
  node_arcswap["Arc-swap adapter"]
end

node_user(("Library user"))

node_user -->|"creates and shares"| node_arc
node_user -->|"builds mutable owner"| node_unique
node_user -->|"uses for FFI"| node_offset
node_user -->|"borrows data"| node_borrow
node_user -->|"uses thin pointer"| node_thin
node_user -->|"stores either type"| node_union
node_arc -->|"converts ownership"| node_unique
node_unique -->|"becomes shareable"| node_arc
node_borrow -->|"clones owner"| node_arc
node_offset -->|"reconstructs owner"| node_arc
node_union -->|"creates borrow"| node_borrow
node_thin -->|"converts representation"| node_arc
node_thin -->|"uses length layout"| node_header
node_arc -->|"allocates header data"| node_header
node_unique -->|"wraps exact-size iterator"| node_iterator
node_arcswap -.->|"implements RefCnt"| node_arc
node_arcswap -.->|"implements RefCnt"| node_thin

click node_arc "https://github.com/manishearth/triomphe/blob/master/src/arc.rs"
click node_unique "https://github.com/manishearth/triomphe/blob/master/src/unique_arc.rs"
click node_borrow "https://github.com/manishearth/triomphe/blob/master/src/arc_borrow.rs"
click node_offset "https://github.com/manishearth/triomphe/blob/master/src/offset_arc.rs"
click node_thin "https://github.com/manishearth/triomphe/blob/master/src/thin_arc.rs"
click node_union "https://github.com/manishearth/triomphe/blob/master/src/arc_union.rs"
click node_header "https://github.com/manishearth/triomphe/blob/master/src/header.rs"
click node_iterator "https://github.com/manishearth/triomphe/blob/master/src/iterator_as_exact_size_iterator.rs"
click node_allocerror "https://github.com/manishearth/triomphe/blob/master/src/alloc_error.rs"
click node_arcswap "https://github.com/manishearth/triomphe/blob/master/src/arc_swap_support.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_arc,node_unique,node_user toneBlue
class node_borrow,node_offset,node_thin,node_union toneAmber
class node_header,node_iterator,node_allocerror,node_arcswap toneMint
```

## Components

### Shared ownership

- [Arc](https://github.com/manishearth/triomphe/blob/master/src/arc.rs): `src/arc.rs`
- [UniqueArc](https://github.com/manishearth/triomphe/blob/master/src/unique_arc.rs): `src/unique_arc.rs`

### Pointer representations

- [ArcBorrow](https://github.com/manishearth/triomphe/blob/master/src/arc_borrow.rs): `src/arc_borrow.rs`
- [OffsetArc](https://github.com/manishearth/triomphe/blob/master/src/offset_arc.rs): `src/offset_arc.rs`
- [ThinArc](https://github.com/manishearth/triomphe/blob/master/src/thin_arc.rs): `src/thin_arc.rs`
- [ArcUnion](https://github.com/manishearth/triomphe/blob/master/src/arc_union.rs): `src/arc_union.rs`

### Allocation and integration

- [Header layouts](https://github.com/manishearth/triomphe/blob/master/src/header.rs): `src/header.rs`
- [Iterator adapter](https://github.com/manishearth/triomphe/blob/master/src/iterator_as_exact_size_iterator.rs): `src/iterator_as_exact_size_iterator.rs`
- [Allocation error](https://github.com/manishearth/triomphe/blob/master/src/alloc_error.rs): `src/alloc_error.rs`
- [Arc-swap adapter](https://github.com/manishearth/triomphe/blob/master/src/arc_swap_support.rs): `src/arc_swap_support.rs`

### Other components

- **Library user**

## Connections

- Library user → Arc: creates and shares (evidence: `README.md`)
- Library user → UniqueArc: builds mutable owner (evidence: `README.md`)
- Library user → OffsetArc: uses for FFI (evidence: `README.md`)
- Library user → ArcBorrow: borrows data (evidence: `README.md`)
- Library user → ThinArc: uses thin pointer (evidence: `README.md`)
- Library user → ArcUnion: stores either type (evidence: `README.md`)
- Arc → UniqueArc: converts ownership (evidence: `src/arc.rs`)
- UniqueArc → Arc: becomes shareable (evidence: `src/unique_arc.rs`)
- ArcBorrow → Arc: clones owner (evidence: `src/arc_borrow.rs`)
- OffsetArc → Arc: reconstructs owner (evidence: `src/offset_arc.rs`)
- ArcUnion → ArcBorrow: creates borrow (evidence: `src/arc_union.rs`)
- ThinArc → Arc: converts representation (evidence: `src/thin_arc.rs`)
- ThinArc → Header layouts: uses length layout (evidence: `src/thin_arc.rs`)
- Arc → Header layouts: allocates header data (evidence: `src/header.rs`)
- UniqueArc → Iterator adapter: wraps exact-size iterator (evidence: `src/unique_arc.rs`)
- Arc-swap adapter → Arc: implements RefCnt (evidence: `src/arc_swap_support.rs`)
- Arc-swap adapter → ThinArc: implements RefCnt (evidence: `src/arc_swap_support.rs`)
