html2pdf_api/
prelude.rs

1//! Convenient imports for common usage patterns.
2//!
3//! This module re-exports the most commonly used types from `html2pdf-api`,
4//! allowing you to quickly get started with a single import.
5//!
6//! # Usage
7//!
8//! ```rust,ignore
9//! use html2pdf_api::prelude::*;
10//! ```
11//!
12//! This imports:
13//!
14//! - [`BrowserPool`] - Main pool type
15//! - [`BrowserPoolBuilder`] - Pool builder
16//! - [`BrowserPoolConfig`] - Configuration struct
17//! - [`BrowserPoolConfigBuilder`] - Configuration builder
18//! - [`BrowserPoolError`] - Error type
19//! - [`Result`] - Result type alias
20//! - [`BrowserHandle`] - RAII browser handle
21//! - [`PoolStats`] - Pool statistics
22//! - [`BrowserFactory`] - Factory trait
23//! - [`ChromeBrowserFactory`] - Chrome factory
24//! - [`Healthcheck`] - Health check trait
25//! - [`SharedBrowserPool`] - Type alias for shared pool
26//!
27//! # Example
28//!
29//! ```rust,ignore
30//! use html2pdf_api::prelude::*;
31//! use std::time::Duration;
32//!
33//! #[tokio::main]
34//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
35//!     let config = BrowserPoolConfigBuilder::new()
36//!         .max_pool_size(5)
37//!         .warmup_count(3)
38//!         .build()?;
39//!
40//!     let pool = BrowserPool::builder()
41//!         .config(config)
42//!         .factory(Box::new(ChromeBrowserFactory::with_defaults()))
43//!         .build()?;
44//!
45//!     pool.warmup().await?;
46//!
47//!     {
48//!         let browser = pool.get()?;
49//!         let tab = browser.new_tab()?;
50//!         // ... use browser
51//!     }
52//!
53//!     Ok(())
54//! }
55//! ```
56
57// Core types
58pub use crate::SharedBrowserPool;
59pub use crate::config::{BrowserPoolConfig, BrowserPoolConfigBuilder};
60pub use crate::error::{BrowserPoolError, Result};
61pub use crate::factory::{BrowserFactory, ChromeBrowserFactory};
62pub use crate::handle::BrowserHandle;
63pub use crate::pool::{BrowserPool, BrowserPoolBuilder};
64pub use crate::stats::PoolStats;
65pub use crate::traits::Healthcheck;
66
67// Feature-gated exports
68#[cfg(feature = "env-config")]
69pub use crate::config::env::{chrome_path_from_env, from_env};
70
71#[cfg(feature = "env-config")]
72pub use crate::pool::init_browser_pool;
73
74// Re-export Arc and Mutex for convenience (commonly needed with SharedBrowserPool)
75pub use std::sync::{Arc, Mutex};