pub struct DeviceDescriptor {
pub user_agent: String,
pub viewport: DeviceViewport,
pub device_scale_factor: f64,
pub is_mobile: bool,
pub has_touch: bool,
pub default_browser_type: String,
}Expand description
Describes a device for browser emulation.
Use with BrowserContext::new_context() options to emulate a specific device,
matching the behavior of playwright.devices["iPhone 13"] in Python/JS.
Device descriptors are accessed by name from [Playwright::devices].
The name is the map key, not a field of the descriptor itself.
§Example
ⓘ
use playwright_rs::protocol::Playwright;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let playwright = Playwright::launch().await?;
let iphone = &playwright.devices()["iPhone 13"];
assert!(iphone.is_mobile);
assert!(iphone.has_touch);
assert_eq!(iphone.default_browser_type, "webkit");
playwright.shutdown().await?;
Ok(())
}See: https://playwright.dev/docs/api/class-playwright#playwright-devices
Fields§
§user_agent: StringThe user-agent string for the device.
viewport: DeviceViewportThe viewport dimensions.
device_scale_factor: f64The device pixel ratio (e.g., 3.0 for Retina displays).
is_mobile: boolWhether the device is a mobile device.
has_touch: boolWhether the device supports touch input.
default_browser_type: StringThe default browser type for the device: "chromium", "firefox", or "webkit".
Trait Implementations§
Source§impl Clone for DeviceDescriptor
impl Clone for DeviceDescriptor
Source§fn clone(&self) -> DeviceDescriptor
fn clone(&self) -> DeviceDescriptor
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 DeviceDescriptor
impl Debug for DeviceDescriptor
Source§impl<'de> Deserialize<'de> for DeviceDescriptor
impl<'de> Deserialize<'de> for DeviceDescriptor
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 DeviceDescriptor
impl RefUnwindSafe for DeviceDescriptor
impl Send for DeviceDescriptor
impl Sync for DeviceDescriptor
impl Unpin for DeviceDescriptor
impl UnsafeUnpin for DeviceDescriptor
impl UnwindSafe for DeviceDescriptor
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