# frostyplanet/crossfire-rs architecture

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

- Interactive diagram: https://gitdiagram.com/frostyplanet/crossfire-rs
- Repository: https://github.com/frostyplanet/crossfire-rs

## Overview

Crossfire is a Rust lock-free channel library for single- and multi-producer/consumer patterns. Applications construct a channel through the SPSC, MPSC, or MPMC APIs, then send and receive through async or blocking endpoints; shared channel state connects those operations to queue flavors and wakeup coordination. The documented product also includes one-shot channels, selection, cancellation channels, wait groups, and async compatibility adapters. Some modules are unsampled; their capabilities are retained from the README, while unverified implementation links are omitted.

Main entry points: [`src/shared.rs`](https://github.com/frostyplanet/crossfire-rs/blob/master/src/shared.rs) (Shared Channel State), [`src/flavor/mod.rs`](https://github.com/frostyplanet/crossfire-rs/blob/master/src/flavor/mod.rs) (Flavor Interface), [`src/async_tx.rs`](https://github.com/frostyplanet/crossfire-rs/blob/master/src/async_tx.rs) (Async Sender), [`src/async_rx.rs`](https://github.com/frostyplanet/crossfire-rs/blob/master/src/async_rx.rs) (Async Receiver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Channel APIs"]
  node_spsc["SPSC API<br/>[spsc.rs]"]
  node_mpsc["MPSC API<br/>[mpsc.rs]"]
  node_mpmc["MPMC API<br/>[mpmc.rs]"]
end

subgraph group_ops["Send And Receive"]
  node_async_tx["Async Sender<br/>[async_tx.rs]"]
  node_async_rx["Async Receiver<br/>[async_rx.rs]"]
  node_blocking_tx["Blocking Sender<br/>[blocking_tx.rs]"]
  node_blocking_rx["Blocking Receiver<br/>[blocking_rx.rs]"]
end

subgraph group_core["Channel Internals"]
  node_shared["Shared Channel State<br/>[shared.rs]"]
  node_registry["Waker Registry<br/>[waker_registry.rs]"]
  node_waker["Wake Mechanism<br/>[waker.rs]"]
  node_backoff["Backoff Policy<br/>[backoff.rs]"]
end

subgraph group_queues["Queue Flavors"]
  node_flavor["Flavor Interface<br/>[mod.rs]"]
  node_array["Array Queues<br/>[array_queue.rs]"]
  node_array_mpsc["MPSC Array Queue"]
  node_array_spsc["SPSC Array Queue"]
  node_seg_queue["Segmented Queue<br/>[seg_queue.rs]"]
  node_one["One-Item Flavors<br/>[one.rs]"]
end

subgraph group_features["Additional Features"]
  node_select["Receiver Selection<br/>[select.rs]"]
  node_multiplex["Multiplex Receiver<br/>[multiplex.rs]"]
  node_oneshot["One-Shot Channels<br/>[oneshot.rs]"]
  node_null["Cancellation Channel<br/>[null.rs]"]
  node_waitgroup["Wait Group<br/>[waitgroup.rs]"]
  node_compat["Async Adapters<br/>[compat.rs]"]
  node_stream["Stream Adapter<br/>[stream.rs]"]
  node_sink["Sink Adapter<br/>[sink.rs]"]
end

node_app(("Application"))

node_app -->|"builds channel"| node_spsc
node_app -->|"builds channel"| node_mpsc
node_app -->|"builds channel"| node_mpmc
node_spsc -.->|"creates endpoints"| node_async_tx
node_spsc -.->|"creates endpoints"| node_async_rx
node_mpsc -.->|"creates endpoints"| node_blocking_tx
node_mpsc -.->|"creates endpoints"| node_blocking_rx
node_mpmc -.->|"creates endpoints"| node_async_tx
node_mpmc -.->|"creates endpoints"| node_async_rx
node_async_tx -->|"uses shared state"| node_shared
node_async_rx -->|"uses shared state"| node_shared
node_blocking_tx -->|"uses shared state"| node_shared
node_blocking_rx -->|"uses shared state"| node_shared
node_shared -->|"uses flavor"| node_flavor
node_shared -->|"notifies endpoints"| node_registry
node_registry -->|"manages wakeups"| node_waker
node_flavor -->|"dispatches queue ops"| node_array
node_flavor -->|"dispatches queue ops"| node_array_mpsc
node_flavor -->|"dispatches queue ops"| node_array_spsc
node_flavor -->|"dispatches queue ops"| node_seg_queue
node_flavor -->|"exposes flavor"| node_one
node_select -->|"selects receivers"| node_shared
node_multiplex -->|"reads channels"| node_shared
node_app -->|"uses one-shot"| node_oneshot
node_app -->|"uses cancellation"| node_null
node_app -->|"selects messages"| node_select
node_app -->|"multiplexes receivers"| node_multiplex
node_app -->|"coordinates tasks"| node_waitgroup
node_async_tx -.->|"converts context"| node_compat
node_async_rx -.->|"converts context"| node_compat
node_async_tx -->|"adapts sending"| node_sink
node_async_rx -->|"adapts receiving"| node_stream
node_blocking_tx -->|"backs off"| node_backoff
node_blocking_rx -->|"backs off"| node_backoff

click node_spsc "https://github.com/frostyplanet/crossfire-rs/blob/master/src/spsc.rs"
click node_mpsc "https://github.com/frostyplanet/crossfire-rs/blob/master/src/mpsc.rs"
click node_mpmc "https://github.com/frostyplanet/crossfire-rs/blob/master/src/mpmc.rs"
click node_async_tx "https://github.com/frostyplanet/crossfire-rs/blob/master/src/async_tx.rs"
click node_async_rx "https://github.com/frostyplanet/crossfire-rs/blob/master/src/async_rx.rs"
click node_blocking_tx "https://github.com/frostyplanet/crossfire-rs/blob/master/src/blocking_tx.rs"
click node_blocking_rx "https://github.com/frostyplanet/crossfire-rs/blob/master/src/blocking_rx.rs"
click node_shared "https://github.com/frostyplanet/crossfire-rs/blob/master/src/shared.rs"
click node_registry "https://github.com/frostyplanet/crossfire-rs/blob/master/src/waker_registry.rs"
click node_waker "https://github.com/frostyplanet/crossfire-rs/blob/master/src/waker.rs"
click node_backoff "https://github.com/frostyplanet/crossfire-rs/blob/master/src/backoff.rs"
click node_flavor "https://github.com/frostyplanet/crossfire-rs/blob/master/src/flavor/mod.rs"
click node_array "https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/array_queue.rs"
click node_array_mpsc "https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/array_queue_mpsc.rs"
click node_array_spsc "https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/array_queue_spsc.rs"
click node_seg_queue "https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/seg_queue.rs"
click node_one "https://github.com/frostyplanet/crossfire-rs/blob/master/src/flavor/one.rs"
click node_select "https://github.com/frostyplanet/crossfire-rs/blob/master/src/select/select.rs"
click node_multiplex "https://github.com/frostyplanet/crossfire-rs/blob/master/src/select/multiplex.rs"
click node_oneshot "https://github.com/frostyplanet/crossfire-rs/blob/master/src/oneshot.rs"
click node_null "https://github.com/frostyplanet/crossfire-rs/blob/master/src/null.rs"
click node_waitgroup "https://github.com/frostyplanet/crossfire-rs/blob/master/src/waitgroup.rs"
click node_compat "https://github.com/frostyplanet/crossfire-rs/blob/master/src/compat.rs"
click node_stream "https://github.com/frostyplanet/crossfire-rs/blob/master/src/stream.rs"
click node_sink "https://github.com/frostyplanet/crossfire-rs/blob/master/src/sink.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_spsc,node_mpsc,node_mpmc toneBlue
class node_async_tx,node_async_rx,node_blocking_tx,node_blocking_rx toneAmber
class node_shared,node_registry,node_waker,node_backoff toneMint
class node_flavor,node_array,node_array_mpsc,node_array_spsc,node_seg_queue,node_one toneRose
class node_select,node_multiplex,node_oneshot,node_null,node_waitgroup,node_compat,node_stream,node_sink,node_app toneIndigo
```

## Components

### Channel APIs

- [SPSC API](https://github.com/frostyplanet/crossfire-rs/blob/master/src/spsc.rs): `src/spsc.rs`
- [MPSC API](https://github.com/frostyplanet/crossfire-rs/blob/master/src/mpsc.rs): `src/mpsc.rs`
- [MPMC API](https://github.com/frostyplanet/crossfire-rs/blob/master/src/mpmc.rs): `src/mpmc.rs`

### Send And Receive

- [Async Sender](https://github.com/frostyplanet/crossfire-rs/blob/master/src/async_tx.rs): `src/async_tx.rs`
- [Async Receiver](https://github.com/frostyplanet/crossfire-rs/blob/master/src/async_rx.rs): `src/async_rx.rs`
- [Blocking Sender](https://github.com/frostyplanet/crossfire-rs/blob/master/src/blocking_tx.rs): `src/blocking_tx.rs`
- [Blocking Receiver](https://github.com/frostyplanet/crossfire-rs/blob/master/src/blocking_rx.rs): `src/blocking_rx.rs`

### Channel Internals

- [Shared Channel State](https://github.com/frostyplanet/crossfire-rs/blob/master/src/shared.rs): `src/shared.rs`
- [Waker Registry](https://github.com/frostyplanet/crossfire-rs/blob/master/src/waker_registry.rs): `src/waker_registry.rs`
- [Wake Mechanism](https://github.com/frostyplanet/crossfire-rs/blob/master/src/waker.rs): `src/waker.rs`
- [Backoff Policy](https://github.com/frostyplanet/crossfire-rs/blob/master/src/backoff.rs): `src/backoff.rs`

### Queue Flavors

- [Flavor Interface](https://github.com/frostyplanet/crossfire-rs/blob/master/src/flavor/mod.rs): `src/flavor/mod.rs`
- [Array Queues](https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/array_queue.rs): `src/crossbeam/array_queue.rs`
- [MPSC Array Queue](https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/array_queue_mpsc.rs): `src/crossbeam/array_queue_mpsc.rs`
- [SPSC Array Queue](https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/array_queue_spsc.rs): `src/crossbeam/array_queue_spsc.rs`
- [Segmented Queue](https://github.com/frostyplanet/crossfire-rs/blob/master/src/crossbeam/seg_queue.rs): `src/crossbeam/seg_queue.rs`
- [One-Item Flavors](https://github.com/frostyplanet/crossfire-rs/blob/master/src/flavor/one.rs): `src/flavor/one.rs`

### Additional Features

- [Receiver Selection](https://github.com/frostyplanet/crossfire-rs/blob/master/src/select/select.rs): `src/select/select.rs`
- [Multiplex Receiver](https://github.com/frostyplanet/crossfire-rs/blob/master/src/select/multiplex.rs): `src/select/multiplex.rs`
- [One-Shot Channels](https://github.com/frostyplanet/crossfire-rs/blob/master/src/oneshot.rs): `src/oneshot.rs`
- [Cancellation Channel](https://github.com/frostyplanet/crossfire-rs/blob/master/src/null.rs): `src/null.rs`
- [Wait Group](https://github.com/frostyplanet/crossfire-rs/blob/master/src/waitgroup.rs): `src/waitgroup.rs`
- [Async Adapters](https://github.com/frostyplanet/crossfire-rs/blob/master/src/compat.rs): `src/compat.rs`
- [Stream Adapter](https://github.com/frostyplanet/crossfire-rs/blob/master/src/stream.rs): `src/stream.rs`
- [Sink Adapter](https://github.com/frostyplanet/crossfire-rs/blob/master/src/sink.rs): `src/sink.rs`

### Other components

- **Application**

## Connections

- Application → SPSC API: builds channel
- Application → MPSC API: builds channel
- Application → MPMC API: builds channel
- SPSC API → Async Sender: creates endpoints
- SPSC API → Async Receiver: creates endpoints
- MPSC API → Blocking Sender: creates endpoints
- MPSC API → Blocking Receiver: creates endpoints
- MPMC API → Async Sender: creates endpoints
- MPMC API → Async Receiver: creates endpoints
- Async Sender → Shared Channel State: uses shared state (evidence: `src/async_tx.rs`)
- Async Receiver → Shared Channel State: uses shared state (evidence: `src/async_rx.rs`)
- Blocking Sender → Shared Channel State: uses shared state (evidence: `src/blocking_tx.rs`)
- Blocking Receiver → Shared Channel State: uses shared state (evidence: `src/blocking_rx.rs`)
- Shared Channel State → Flavor Interface: uses flavor (evidence: `src/shared.rs`)
- Shared Channel State → Waker Registry: notifies endpoints (evidence: `src/shared.rs`)
- Waker Registry → Wake Mechanism: manages wakeups (evidence: `src/waker_registry.rs`)
- Flavor Interface → Array Queues: dispatches queue ops (evidence: `src/flavor/mod.rs`)
- Flavor Interface → MPSC Array Queue: dispatches queue ops (evidence: `src/flavor/mod.rs`)
- Flavor Interface → SPSC Array Queue: dispatches queue ops (evidence: `src/flavor/mod.rs`)
- Flavor Interface → Segmented Queue: dispatches queue ops (evidence: `src/flavor/mod.rs`)
- Flavor Interface → One-Item Flavors: exposes flavor (evidence: `src/flavor/mod.rs`)
- Receiver Selection → Shared Channel State: selects receivers (evidence: `src/select/select.rs`)
- Multiplex Receiver → Shared Channel State: reads channels (evidence: `src/select/multiplex.rs`)
- Application → One-Shot Channels: uses one-shot
- Application → Cancellation Channel: uses cancellation
- Application → Receiver Selection: selects messages
- Application → Multiplex Receiver: multiplexes receivers
- Application → Wait Group: coordinates tasks
- Async Sender → Async Adapters: converts context
- Async Receiver → Async Adapters: converts context
- Async Sender → Sink Adapter: adapts sending (evidence: `src/async_tx.rs`)
- Async Receiver → Stream Adapter: adapts receiving (evidence: `src/async_rx.rs`)
- Blocking Sender → Backoff Policy: backs off (evidence: `src/blocking_tx.rs`)
- Blocking Receiver → Backoff Policy: backs off (evidence: `src/blocking_rx.rs`)
