Skip to main content

parse_owned

Function parse_owned 

Source
pub fn parse_owned(input: String) -> Result<Document, HtmlError>
Expand description

Parse an owned String into a Document, transferring the allocation.

Unlike parse, this avoids copying the input bytes into the arena’s source buffer — the String’s allocation is transferred directly. Use this when the caller already owns the input (e.g., from an HTTP response body).

§Errors

Returns HtmlError::InputTooLarge if the input exceeds 256 MiB.

§Example

use fhp_tree::parse_owned;

let html = String::from("<div><p>Hello</p></div>");
let doc = parse_owned(html).unwrap();
assert_eq!(doc.root().text_content(), "Hello");