html_generator::performance

Function async_generate_html

Source
pub async fn async_generate_html(markdown: &str) -> Result<String>
Expand description

Asynchronously generates HTML from Markdown content.

Processes Markdown in a separate thread to avoid blocking the async runtime, optimized for efficient memory usage with larger content.

§Arguments

  • markdown - Markdown content to convert to HTML

§Returns

Returns the generated HTML content if successful.

§Errors

Returns HtmlError if:

  • Thread spawning fails
  • Markdown processing fails

§Examples

let markdown = "# Hello\n\nThis is a test.";
let html = async_generate_html(markdown).await?;
println!("Generated HTML length: {}", html.len());