Expand description
Convenient imports for common usage patterns.
This module re-exports the most commonly used types from html2pdf-api,
allowing you to quickly get started with a single import.
§Usage
ⓘ
use html2pdf_api::prelude::*;This imports:
BrowserPool- Main pool typeBrowserPoolBuilder- Pool builderBrowserPoolConfig- Configuration structBrowserPoolConfigBuilder- Configuration builderBrowserPoolError- Error typeResult- Result type aliasBrowserHandle- RAII browser handlePoolStats- Pool statisticsBrowserFactory- Factory traitChromeBrowserFactory- Chrome factoryHealthcheck- Health check traitSharedBrowserPool- Type alias for shared pool
§Example
ⓘ
use html2pdf_api::prelude::*;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = BrowserPoolConfigBuilder::new()
.max_pool_size(5)
.warmup_count(3)
.build()?;
let pool = BrowserPool::builder()
.config(config)
.factory(Box::new(ChromeBrowserFactory::with_defaults()))
.build()?;
pool.warmup().await?;
{
let browser = pool.get()?;
let tab = browser.new_tab()?;
// ... use browser
}
Ok(())
}Re-exports§
pub use crate::config::BrowserPoolConfig;pub use crate::config::BrowserPoolConfigBuilder;pub use crate::error::BrowserPoolError;pub use crate::error::Result;pub use crate::factory::BrowserFactory;pub use crate::factory::ChromeBrowserFactory;pub use crate::handle::BrowserHandle;pub use crate::pool::BrowserPool;pub use crate::pool::BrowserPoolBuilder;pub use crate::stats::PoolStats;pub use crate::traits::Healthcheck;pub use crate::config::env::chrome_path_from_env;pub use crate::config::env::from_env;pub use crate::pool::init_browser_pool;