--- marp: true @marp-team/marp-cli v4.4.0 (w/ @marp-team/marp-core v4.3.0) title: Firefox Web APIs with crates over FFI author: Ed Guloien date: Sept 2026 paginate: true footer: Sept 2026 html: "true" --- # Firefox Web APIs with Crates (over FFI) ### Ed Guloien --- ## about://ed-guloien
--- ## Interop 2025 ![bg width:600px](images/interop-2025-2.png) ![bg width:600px](images/interop-2025-3.png) --- ## URLPattern Web API ```rust // JS // build a pattern const pattern = new URLPattern({ pathname: "/books/:id" }); // check for match pattern.test("https://example.com/books/123"); // get match info by component pattern.exec("https://example.com/books/123").pathname.groups ``` --- ## Denoland & Firefox ![bg width:400px](images/denoland-urlpattern.png) ![bg width:600px](images/urlpattern-fission.drawio.png) ------- ## Web API Call Flow ![bg center width:1000px](images/urlpattern-call-flow.drawio.png) ----- ## Urlpattern Crate API ![bg center width:850px](images/urlpattern-details-simple.drawio.png) ---- ## Glue Crate ``` let pattern = quirks::parse::(input); let results = quirks::process_match(pattern, input); // call it a day ``` ----- ## Reality Sets In (Memory Concerns) ``` #[repr(transparent)] pub struct UrlPatternGlue(pub *mut c_void); if let Ok(pattern) = quirks::parse::(input, ...) { unsafe { *res = UrlPatternGlue(Box::into_raw(Box::new(pattern)) as *mut _); } } glue::process_match(..., res: *mut MatchResults, other: MaybeString) glue::doing_thing(..., res: &mut ThinVec<>); ``` ---- ## Pattern Re-use; Marshaling ![bg center width:1000px](images/urlpattern-pattern-reuse.drawio.png) ------ ## 99.8% ``` regex::Regex != EcmaScript Regex ``` ---- ## Spidermonkey Challenges (many) ![bg center width:825px](images/urlpattern-spidermonkey-challenges.drawio.png) ----- ## And if you do all that... ... ------- ## Phew! ![width:900px](images/urlpattern-interop-2025-results.png) #### References - http://qubridge.io - https://wpt.fyi/interop-2025 - https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API - https://searchfox.org/firefox-main - https://github.com/denoland/rust-urlpattern - See also: https://manuelbucher.com/blog/rust-gecko/