pub struct Browser { /* private fields */ }Implementations§
Source§impl Browser
impl Browser
Sourcepub async fn new_with_head() -> Result<Self>
pub async fn new_with_head() -> Result<Self>
Launches a new browser instance with head visible.
Sourcepub async fn capture_html(&self, html: &str, selector: &str) -> Result<String>
pub async fn capture_html(&self, html: &str, selector: &str) -> Result<String>
Captures a screenshot of HTML content clipped to the given selector using default options.
Sourcepub async fn capture_html_with_options(
&self,
html: &str,
selector: &str,
opts: CaptureOptions,
) -> Result<String>
pub async fn capture_html_with_options( &self, html: &str, selector: &str, opts: CaptureOptions, ) -> Result<String>
Captures a screenshot with options such as format, quality, and viewport.
§Example
ⓘ
let options = CaptureOptions::new()
.with_format(ImageFormat::Png)
.with_viewport(Viewport::new(1920, 1080).with_device_scale_factor(2.0));
let base64 = browser.capture_html_with_options(html, "body", options).await?;Sourcepub async fn capture_html_hidpi(
&self,
html: &str,
selector: &str,
scale: f64,
) -> Result<String>
pub async fn capture_html_hidpi( &self, html: &str, selector: &str, scale: f64, ) -> Result<String>
Captures a high-DPI screenshot with the specified scale factor.
Convenience method for getting sharper images without manually configuring viewport and options.
§Arguments
html- HTML content to renderselector- CSS selector for the element to capturescale- Device scale factor (2.0 for retina, 3.0 for ultra-high DPI)
Sourcepub async fn close_async(&self) -> Result<()>
pub async fn close_async(&self) -> Result<()>
Closes the browser process and cleans up resources asynchronously.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Browser
impl !RefUnwindSafe for Browser
impl Send for Browser
impl Sync for Browser
impl Unpin for Browser
impl !UnwindSafe for Browser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more