spider-markup5ever_rcdom
A Send/Sync-friendly fork of markup5ever_rcdom on the spider-rs atomic-tendril stack.
Why this fork?
Upstream markup5ever_rcdom 0.38 produces an Rc<Node> DOM that is !Send — both because of Rc itself and because it stores StrTendril (which is !Send in upstream tendril). That blocks any future holding the parsed DOM from being Send-able for tokio::spawn on a multi-threaded runtime.
This fork makes two changes:
- Depends on the spider- fork stack*:
spider-tendril(atomic refcount default),spider-markup5ever,spider-html5ever. The Atomic-tendril propagation is automatic — no source code changes needed for the tendril side. - Adds
unsafe impl Send + Sync for Nodewith a documented soundness invariant: aNodeis owned by exactly one task at a time. The future may move between tokio worker threads (work-stealing), but only one thread polls it at any instant, so no two threads ever access the sameNodesimultaneously. Cloning aHandleand using one clone on another thread while the original is still live on the source thread is undefined behavior — don't do that.
Arc<Node>: Send requires Node: Send + Sync. With the unsafe impl, this holds, and the entire DOM can move between threads as a unit.
Use
[]
= "0.39"
use ;
The library still imports as markup5ever_rcdom, so existing code requires no changes — only the dependency line in Cargo.toml needs to swap. Pair with spider-html5ever and spider-markup5ever for the full Send-able parser-and-DOM stack.
Disclaimer (preserved from upstream)
This crate is built for the express purpose of writing automated tests for the html5ever and xml5ever crates. It is not intended to be a production-quality DOM implementation, and has not been fuzzed or tested against arbitrary, malicious, or nontrivial inputs. No maintenance or support for any such issues will be provided. If you use this DOM implementation in a production, user-facing system, you do so at your own risk.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option, matching the upstream markup5ever_rcdom license.