pub struct ChromiumSetTab { /* private fields */ }Available on crate feature
cdp only.Expand description
标签设置句柄(tab.set())。
Implementations§
Source§impl ChromiumSetTab
impl ChromiumSetTab
Sourcepub async fn emulate_media(
&self,
media: Option<&str>,
features: &[(&str, &str)],
) -> Result<()>
pub async fn emulate_media( &self, media: Option<&str>, features: &[(&str, &str)], ) -> Result<()>
模拟媒体类型与特性(Emulation.setEmulatedMedia)。media 如 "print"/"screen";
features 如 [("prefers-color-scheme","dark")]。
Sourcepub async fn emulate_dark(&self, dark: bool) -> Result<()>
pub async fn emulate_dark(&self, dark: bool) -> Result<()>
模拟深色 / 浅色模式(prefers-color-scheme)。
Sourcepub async fn offline(&self, on: bool) -> Result<()>
pub async fn offline(&self, on: bool) -> Result<()>
设置离线 / 在线(Network.emulateNetworkConditions)。
Sourcepub async fn network_conditions(&self, nc: &NetworkConditions) -> Result<()>
pub async fn network_conditions(&self, nc: &NetworkConditions) -> Result<()>
模拟网络条件(离线 / 限速)。
Sourcepub async fn cpu_throttling(&self, rate: f64) -> Result<()>
pub async fn cpu_throttling(&self, rate: f64) -> Result<()>
CPU 节流(Emulation.setCPUThrottlingRate)。rate=4.0 即降速到 1/4。
Sourcepub async fn grant_permissions(
&self,
origin: &str,
permissions: &[&str],
) -> Result<()>
pub async fn grant_permissions( &self, origin: &str, permissions: &[&str], ) -> Result<()>
给某 origin 授予权限(Browser.grantPermissions),如
["geolocation","clipboard-read","notifications","camera","microphone"]。
Sourcepub async fn reset_permissions(&self) -> Result<()>
pub async fn reset_permissions(&self) -> Result<()>
重置(撤销)所有此前授予的权限(Browser.resetPermissions)。
Sourcepub async fn touch(&self, on: bool) -> Result<()>
pub async fn touch(&self, on: bool) -> Result<()>
开/关触摸事件模拟(Emulation.setTouchEmulationEnabled)。
Sourcepub async fn device(&self, d: &Device) -> Result<()>
pub async fn device(&self, d: &Device) -> Result<()>
一把梭模拟设备(UA + 视口 + DPR + mobile + 触摸)。见 Device 预设。
Sourcepub async fn clear_device(&self) -> Result<()>
pub async fn clear_device(&self) -> Result<()>
清除设备模拟,恢复真实视口(Emulation.clearDeviceMetricsOverride)。
Sourcepub async fn local_storage_set(&self, key: &str, value: &str) -> Result<()>
pub async fn local_storage_set(&self, key: &str, value: &str) -> Result<()>
写 localStorage(便捷,内部走 Runtime.evaluate)。
Sourcepub async fn local_storage_get(&self, key: &str) -> Result<Option<String>>
pub async fn local_storage_get(&self, key: &str) -> Result<Option<String>>
读 localStorage(不存在返回 None)。
Sourcepub async fn local_storage_remove(&self, key: &str) -> Result<()>
pub async fn local_storage_remove(&self, key: &str) -> Result<()>
删 localStorage 项。
Sourcepub async fn local_storage_clear(&self) -> Result<()>
pub async fn local_storage_clear(&self) -> Result<()>
清空 localStorage。
Sourcepub async fn session_storage_set(&self, key: &str, value: &str) -> Result<()>
pub async fn session_storage_set(&self, key: &str, value: &str) -> Result<()>
写 sessionStorage。
Sourcepub async fn session_storage_remove(&self, key: &str) -> Result<()>
pub async fn session_storage_remove(&self, key: &str) -> Result<()>
删 sessionStorage 项。
Sourcepub async fn session_storage_clear(&self) -> Result<()>
pub async fn session_storage_clear(&self) -> Result<()>
清空 sessionStorage。
Auto Trait Implementations§
impl !RefUnwindSafe for ChromiumSetTab
impl !UnwindSafe for ChromiumSetTab
impl Freeze for ChromiumSetTab
impl Send for ChromiumSetTab
impl Sync for ChromiumSetTab
impl Unpin for ChromiumSetTab
impl UnsafeUnpin for ChromiumSetTab
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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