Skip to main content

ViewportManager

Struct ViewportManager 

Source
pub struct ViewportManager { /* private fields */ }
Expand description

Manages viewport and device emulation

Implementations§

Source§

impl ViewportManager

Source

pub fn new(client: Arc<CdpClient>) -> Self

Create a new viewport manager

Source

pub async fn set_device_metrics(&self, config: &ViewportConfig) -> Result<()>

Set device metrics override (emulate a specific device viewport)

Source

pub async fn clear_device_metrics(&self) -> Result<()>

Clear device metrics override (restore default viewport)

Source

pub async fn set_touch_emulation(&self, enabled: bool) -> Result<()>

Set touch emulation

Source

pub async fn set_user_agent( &self, user_agent: &str, accept_language: Option<&str>, ) -> Result<()>

Set user agent override

Source

pub async fn set_geolocation( &self, latitude: f64, longitude: f64, accuracy: Option<f64>, ) -> Result<()>

Set geolocation override

Source

pub async fn clear_geolocation(&self) -> Result<()>

Clear geolocation override

Source

pub async fn set_timezone(&self, timezone_id: &str) -> Result<()>

Set timezone override

Source

pub async fn set_media_features( &self, media_type: Option<&str>, features: Vec<MediaFeature>, ) -> Result<()>

Set emulated media features (prefers-color-scheme, prefers-reduced-motion, etc.)

Source

pub async fn clear_media_features(&self) -> Result<()>

Clear emulated media (restore defaults)

Source

pub async fn set_color_scheme(&self, scheme: ColorScheme) -> Result<()>

Set color scheme (convenience wrapper for prefers-color-scheme)

Source

pub async fn set_vision_deficiency( &self, deficiency: VisionDeficiency, ) -> Result<()>

Set vision deficiency emulation for accessibility testing

Source

pub async fn set_locale(&self, locale: &str) -> Result<()>

Set locale override (affects navigator.language and date formatting)

Source

pub async fn clear_locale(&self) -> Result<()>

Clear locale override (restore system default)

Source

pub async fn override_languages_and_fonts( &self, languages: Vec<String>, font_families: Option<Vec<String>>, ) -> Result<()>

Override navigator.languages and optionally font-family lists via JS. This ensures font rendering consistency across environments.

Source

pub async fn preset_device(&self, preset: &DevicePreset) -> Result<()>

Apply a device preset (viewport + user agent + touch in one call)

Source

pub async fn get_metrics(&self) -> Result<DeviceMetrics>

Get current device metrics via JavaScript

Trait Implementations§

Source§

impl Clone for ViewportManager

Source§

fn clone(&self) -> ViewportManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ViewportManager

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more