Stash an outgoing tab's emulation state under its target id so it can be restored when that tab becomes active again. Empty state is dropped so the map doesn't accumulate blank entries for every tab ever visited. Pure (no I/O) — this is the per-tab isolation invariant and is unit-tested below.
(
saved: &mut std::collections::HashMap<String, TabEmulation>,
target: String,
state: TabEmulation,
)
| 153 | /// map doesn't accumulate blank entries for every tab ever visited. Pure (no |
| 154 | /// I/O) — this is the per-tab isolation invariant and is unit-tested below. |
| 155 | fn stash_tab_emulation( |
| 156 | saved: &mut std::collections::HashMap<String, TabEmulation>, |
| 157 | target: String, |
| 158 | state: TabEmulation, |
| 159 | ) { |
| 160 | if !state.is_empty() { |
| 161 | saved.insert(target, state); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | impl CdpClient { |
| 166 | /// Connect to Chrome via WebSocket and return a CDP client. |