# 2teez/skan architecture

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

- Interactive diagram: https://gitdiagram.com/2teez/skan
- Repository: https://github.com/2teez/skan

## Overview

Skan is a small Rust scanner library. A caller constructs a Scanner from a string or Read source, then consumes bytes, words, lines, or parsed numbers; numeric failures and exhausted input are reported as ScannerError. The graph separates input acquisition, token splitting, typed parsing, and numeric type constraints, while byte iteration remains a Scanner capability. The README documents the main workflow; the source excerpt confirms implementation details and the call from typed parsing to generic number parsing.

Main entry points: [`src/scanner.rs`](https://github.com/2teez/skan/blob/main/src/scanner.rs) (Numeric parsing), [`src/numbers.rs`](https://github.com/2teez/skan/blob/main/src/numbers.rs) (Numeric type traits)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scan["Scanner runtime"]
  node_scanner["Scanner state<br/>[scanner.rs]"]
  node_byte_access["Byte iteration<br/>[scanner.rs]"]
  node_tokenization["Word and line splitting<br/>[scanner.rs]"]
end

subgraph group_parse["Parsing support"]
  node_numeric_parse["Numeric parsing<br/>[scanner.rs]"]
  node_number_types["Numeric type traits<br/>[numbers.rs]"]
  node_scanner_errors["Scanner errors<br/>[scanner.rs]"]
end

node_caller(("Library caller"))
node_read_source["Read source"]

node_caller -->|"creates"| node_scanner
node_read_source -->|"provides bytes"| node_scanner
node_caller -->|"iterates bytes"| node_byte_access
node_caller -->|"reads words or lines"| node_tokenization
node_scanner -->|"splits input"| node_tokenization
node_caller -->|"requests number"| node_numeric_parse
node_numeric_parse -->|"constrained by"| node_number_types
node_numeric_parse -->|"returns errors"| node_scanner_errors

click node_scanner "https://github.com/2teez/skan/blob/main/src/scanner.rs"
click node_byte_access "https://github.com/2teez/skan/blob/main/src/scanner.rs"
click node_tokenization "https://github.com/2teez/skan/blob/main/src/scanner.rs"
click node_numeric_parse "https://github.com/2teez/skan/blob/main/src/scanner.rs"
click node_number_types "https://github.com/2teez/skan/blob/main/src/numbers.rs"
click node_scanner_errors "https://github.com/2teez/skan/blob/main/src/scanner.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_scanner,node_byte_access,node_tokenization toneBlue
class node_numeric_parse,node_number_types,node_scanner_errors toneAmber
class node_caller,node_read_source toneIndigo
```

## Components

### Scanner runtime

- [Scanner state](https://github.com/2teez/skan/blob/main/src/scanner.rs): `src/scanner.rs`
- [Byte iteration](https://github.com/2teez/skan/blob/main/src/scanner.rs): `src/scanner.rs`
- [Word and line splitting](https://github.com/2teez/skan/blob/main/src/scanner.rs): `src/scanner.rs`

### Parsing support

- [Numeric parsing](https://github.com/2teez/skan/blob/main/src/scanner.rs): `src/scanner.rs`
- [Numeric type traits](https://github.com/2teez/skan/blob/main/src/numbers.rs): `src/numbers.rs`
- [Scanner errors](https://github.com/2teez/skan/blob/main/src/scanner.rs): `src/scanner.rs`

### Other components

- **Library caller**
- **Read source**

## Connections

- Library caller → Scanner state: creates (evidence: `README.md`)
- Read source → Scanner state: provides bytes (evidence: `src/scanner.rs`)
- Library caller → Byte iteration: iterates bytes (evidence: `README.md`)
- Library caller → Word and line splitting: reads words or lines (evidence: `README.md`)
- Scanner state → Word and line splitting: splits input (evidence: `src/scanner.rs`)
- Library caller → Numeric parsing: requests number (evidence: `README.md`)
- Numeric parsing → Numeric type traits: constrained by (evidence: `src/scanner.rs`)
- Numeric parsing → Scanner errors: returns errors (evidence: `src/scanner.rs`)
