pub struct ContextConfig {Show 18 fields
pub name: String,
pub viewport_width: u32,
pub viewport_height: u32,
pub device_scale_factor: f64,
pub is_mobile: bool,
pub has_touch: bool,
pub user_agent: Option<String>,
pub locale: Option<String>,
pub timezone: Option<String>,
pub geolocation: Option<Geolocation>,
pub permissions: Vec<String>,
pub extra_headers: HashMap<String, String>,
pub offline: bool,
pub storage_state: Option<StorageState>,
pub accept_downloads: bool,
pub record_video: bool,
pub record_har: bool,
pub ignore_https_errors: bool,
}Expand description
Configuration for a browser context
Fields§
§name: StringContext name/ID
viewport_width: u32Viewport width
viewport_height: u32Viewport height
device_scale_factor: f64Device scale factor
is_mobile: boolIs mobile device
has_touch: boolHas touch support
user_agent: Option<String>User agent string
locale: Option<String>Locale
timezone: Option<String>Timezone
geolocation: Option<Geolocation>Geolocation
permissions: Vec<String>Permissions
extra_headers: HashMap<String, String>Extra HTTP headers
offline: boolOffline mode
storage_state: Option<StorageState>Initial storage state
accept_downloads: boolAccept downloads
record_video: boolRecord video
record_har: boolRecord HAR
ignore_https_errors: boolIgnore HTTPS errors
Implementations§
Source§impl ContextConfig
impl ContextConfig
Sourcepub const fn with_viewport(self, width: u32, height: u32) -> Self
pub const fn with_viewport(self, width: u32, height: u32) -> Self
Set viewport size
Sourcepub const fn with_device_scale(self, scale: f64) -> Self
pub const fn with_device_scale(self, scale: f64) -> Self
Set device scale factor
Sourcepub fn with_user_agent(self, user_agent: &str) -> Self
pub fn with_user_agent(self, user_agent: &str) -> Self
Set user agent
Sourcepub fn with_locale(self, locale: &str) -> Self
pub fn with_locale(self, locale: &str) -> Self
Set locale
Sourcepub fn with_timezone(self, timezone: &str) -> Self
pub fn with_timezone(self, timezone: &str) -> Self
Set timezone
Sourcepub fn with_geolocation(self, lat: f64, lng: f64) -> Self
pub fn with_geolocation(self, lat: f64, lng: f64) -> Self
Set geolocation
Sourcepub fn with_permission(self, permission: &str) -> Self
pub fn with_permission(self, permission: &str) -> Self
Add permission
Sourcepub fn with_header(self, key: &str, value: &str) -> Self
pub fn with_header(self, key: &str, value: &str) -> Self
Add extra header
Sourcepub fn with_storage_state(self, state: StorageState) -> Self
pub fn with_storage_state(self, state: StorageState) -> Self
Set storage state
Sourcepub const fn with_video(self) -> Self
pub const fn with_video(self) -> Self
Enable video recording
Sourcepub const fn ignore_https_errors(self) -> Self
pub const fn ignore_https_errors(self) -> Self
Ignore HTTPS errors
Trait Implementations§
Source§impl Clone for ContextConfig
impl Clone for ContextConfig
Source§fn clone(&self) -> ContextConfig
fn clone(&self) -> ContextConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextConfig
impl Debug for ContextConfig
Source§impl Default for ContextConfig
impl Default for ContextConfig
Source§impl<'de> Deserialize<'de> for ContextConfig
impl<'de> Deserialize<'de> for ContextConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContextConfig
impl RefUnwindSafe for ContextConfig
impl Send for ContextConfig
impl Sync for ContextConfig
impl Unpin for ContextConfig
impl UnsafeUnpin for ContextConfig
impl UnwindSafe for ContextConfig
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