[core] Detect: Marks hold on and off sets; arena-core 0.2.0 checks pass

Marks keeps one verdict per exe: on ("This is a game") or off ("This is
not a game"). detect: Launched > marked off (None) > marked on (Marked,
with the library game if any) > InstallDir. Serde writes
{"on": [...], "off": [...]} and still reads the plain array as on;
an exe in both lists is refused, MAX_MARKS counts both.

Also: collapsible-if for clippy, rustfmt, README and FORMATS updated.
Checked: cargo test -p arena-core (183 passed), clippy -D warnings,
fmt --check, check for wasm32-unknown-unknown and aarch64-linux-android.
This commit is contained in:
2026-11-26 03:27:03 +01:00
parent 43701bbadc
commit 95d031fef9
6 changed files with 251 additions and 64 deletions
+13 -7
View File
@@ -28,7 +28,7 @@ reads capped bytes and passes them in.
| `MAX_HOST` | 253 bytes | the URL's host | `BadValue("url")` |
| `MAX_GAMES` | 100 000 | games one `merge` call considers | the rest are dropped |
| `MAX_FRAMES` | 1 048 576 | frametimes one `frames::stats` call takes | `None` |
| `MAX_MARKS` | 4096 | exes marked as games (`detect::Marks`) | `TooMany("marks")` |
| `MAX_MARKS` | 4096 | exes marked on or off, together (`detect::Marks`) | `TooMany("marks")` |
| `MAX_HOTKEY` | 64 bytes | shortcut text for `hotkey::parse` | `HotkeyError::TooLong` |
## Errors
@@ -214,12 +214,18 @@ frames, seconds }`. `avg_fps = frames / seconds`; the lows are `1000 / frametime
60 frames are never stutters. `None` for an empty series, over `MAX_FRAMES`, any NaN, infinite or negative value,
or no time at all (zeros alone).
**`detect::detect(exe, launched_by_arena, library, marks)`**, first match wins: `Launched` (Arena started it; the
game if its folder holds the exe), `InstallDir` (the game's own launch exe, else the deepest `install_dir` strictly
containing the exe; drive roots never count as a containing folder), `Marked` (exactly this exe, `game: None`).
Otherwise `None`: an exe outside every install folder is never auto-detected. Comparison is component-wise and
ignores case; `WinPath` already refuses `..`, `.`, UNC and `\\?\`. `Marks` serialises as a sorted JSON array of
paths; loading re-checks each path and folds spellings of one exe.
**`detect::detect(exe, launched_by_arena, library, marks)`**, first match wins: `Launched` (Arena started it,
whatever the marks; the game if the library owns the exe); `None` when the exe is marked **off** ("This is not a
game"); `Marked` when it is marked **on** ("This is a game"; the game if the library owns the exe); `InstallDir`
(the game's own launch exe, else the deepest `install_dir` strictly containing the exe; drive roots never count as
a containing folder). Otherwise `None`: an exe outside every install folder is never auto-detected. Comparison is
component-wise and ignores case; `WinPath` already refuses `..`, `.`, UNC and `\\?\`. Marks are per exe, never
per folder, and an exe is in at most one set.
`Marks` serialises as `{"on": [paths], "off": [paths]}`, each sorted by the case-folded path. Loading also takes a
plain array of paths as `on` (the first 0.2.0 form), treats a missing list as empty, refuses unknown keys, re-checks
each path, folds spellings of one exe, and refuses an exe in both lists (`Duplicate("marks")`) or more than
`MAX_MARKS` in all (`TooMany("marks")`).
**`hotkey::parse(&str)`**: `Mod+...+Key`, spaces around parts ignored, names ignore case. Modifiers `Ctrl Alt Shift
Win` (each once); key `A`–`Z`, `0`–`9`, `F1`–`F24`, last. Errors: `Empty`, `TooLong`, `Malformed` (empty part),