Skip to content

spider-rs/markup5ever_rcdom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spider-markup5ever_rcdom

A Send/Sync-friendly fork of markup5ever_rcdom on the spider-rs atomic-tendril stack.

crates.io

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:

  1. 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.
  2. Adds unsafe impl Send + Sync for Node with a documented soundness invariant: a Node is 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 same Node simultaneously. Cloning a Handle and 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

[dependencies]
spider-markup5ever_rcdom = "0.39"
use markup5ever_rcdom::{Handle, NodeData, RcDom, SerializableHandle};

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.

About

Send/Sync-friendly fork of markup5ever_rcdom on the spider-* atomic-tendril stack

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages