Skip to main content

BrowserContext

Struct BrowserContext 

Source
pub struct BrowserContext {
    pub id: String,
    pub config: ContextConfig,
    pub state: ContextState,
    pub created_at: Instant,
    pub error_message: Option<String>,
    /* private fields */
}
Expand description

A browser context instance

Fields§

§id: String

Context ID

§config: ContextConfig

Configuration

§state: ContextState

Current state

§created_at: Instant

Creation time

§error_message: Option<String>

Error message if state is Error

Implementations§

Source§

impl BrowserContext

Source

pub fn new(id: &str, config: ContextConfig) -> Self

Create a new context

Source

pub fn ready(&mut self)

Mark context as ready

Source

pub fn acquire(&mut self)

Mark context as in use

Source

pub fn release(&mut self)

Release context back to pool

Source

pub fn close(&mut self)

Close the context

Source

pub fn set_error(&mut self, message: &str)

Set error state

Source

pub const fn is_available(&self) -> bool

Check if context is available

Source

pub const fn is_in_use(&self) -> bool

Check if context is in use

Source

pub const fn is_closed(&self) -> bool

Check if context is closed

Source

pub fn age_ms(&self) -> u64

Get age in milliseconds

Source

pub fn new_page(&self) -> String

Create a new page

Source

pub fn close_page(&self, page_id: &str)

Close a page

Source

pub fn page_count(&self) -> usize

Get page count

Source

pub fn storage_state(&self) -> StorageState

Get storage state

Source

pub fn clear_storage(&self)

Clear storage

Add cookie

Source

pub fn clear_cookies(&self)

Clear cookies

Trait Implementations§

Source§

impl Debug for BrowserContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.