Parse a canonical token string into `(snapshot_id, element_index)`. Returns `None` on any shape error (unknown prefix, missing colon, non-hex, non-decimal). The token strings are produced by [`format_token`] only — consumers MUST treat the format as opaque and never construct one by hand.
(token: &str)
| 287 | /// non-decimal). The token strings are produced by [`format_token`] only — |
| 288 | /// consumers MUST treat the format as opaque and never construct one by hand. |
| 289 | fn parse_token(token: &str) -> Option<(u32, usize)> { |
| 290 | let body = token.strip_prefix('s')?; |
| 291 | let (hex, idx) = body.split_once(':')?; |
| 292 | if hex.len() != 4 { |
| 293 | return None; |
| 294 | } |
| 295 | let sid = u32::from_str_radix(hex, 16).ok()?; |
| 296 | let idx = idx.parse::<usize>().ok()?; |
| 297 | Some((sid, idx)) |
| 298 | } |
| 299 | |
| 300 | /// Process-global handle to the token registry. Used by a platform's |
| 301 | /// window-state implementation (to register a fresh snapshot) and every |