MCPcopy Create free account
hub / github.com/GCWing/BitFun / parse_token

Function parse_token

src/crates/execution/tool-contracts/src/element_token.rs:289–298  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
289fn 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

Callers 2

resolveMethod · 0.85

Calls 2

lenMethod · 0.45
okMethod · 0.45