Skip to content

Make async ergonomics nicer. #478

Open
@b7-7b

Description

@b7-7b

Using html5ever in async code is painful, because of Cell in StrTendril. As far as I can tell, that choice is for performance reasons (the documentation claims that the use of non-thread-safe primitives is explained in README.md, but no such explanation exists anywhere I can find) but in my use case I'm quite happy to trade a bit of performance for massively enhanced ergonomics with async.

To that end, I'd like to see something which swaps out StrTendril (aka Tendril<UTF8, NonAtomic>) for Tendril<UTF8, Atomic>. A feature to enable atomicity seems reasonable, but there might be a better option. As far as I can tell that's a completely source-compatible change, so this can probably be implemented with something like:

#[cfg(not(feature="atomic"))]
type H5ETendril = tendril::StrTendril;
#[cfg(feature="atomic")]
type H5ETendril = tendril::Tendril<tendril::UTF8, tendril::Atomic>;

and then replacing references to tendril::StrTendril with crate::H5ETendril.

Obviously the names can be bikeshedded. Those are the first ones I came up with.

Whether this belongs in this crate or tendril is also up for debate, but in my opinion: people using tendril directly already have plenty of ways to give themselves atomicity, and changing defaults through a feature there would just lead to dependency hell.

I can put in a PR, if it does turn out to be that simple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions