pub struct JSHandle { /* private fields */ }Expand description
JSHandle 本地状态。
@trace REQ-BAO-API-006 [class:JSHandle]
Implementations§
Source§impl JSHandle
impl JSHandle
Sourcepub fn new(
execution_context: Rc<ExecutionContext>,
remote_object_id: impl Into<String>,
) -> JSHandle
pub fn new( execution_context: Rc<ExecutionContext>, remote_object_id: impl Into<String>, ) -> JSHandle
构造 JSHandle(初始化为空缓存)。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn remote_object_id(&self) -> &str
pub fn remote_object_id(&self) -> &str
远程对象 ID(从 Runtime/DOM 返回的 objectId)。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn execution_context(&self) -> &ExecutionContext
pub fn execution_context(&self) -> &ExecutionContext
所属 ExecutionContext。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn is_disposed(&self) -> bool
pub fn is_disposed(&self) -> bool
是否已 dispose(本地标记)。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn as_element(&self) -> Option<&ElementHandle>
pub fn as_element(&self) -> Option<&ElementHandle>
类型检查。JSHandle 永远返回 None;ElementHandle override 返回 Some(&self)。
默认实现返回 None。ElementHandle 调用方应通过此方法做“动态分发“。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn json_value(&self) -> Option<Value>
pub fn json_value(&self) -> Option<Value>
读取缓存的 JSON value(不调用 CDP)。
调用方需先通过 B 类方法(Runtime.callFunctionOn + JSON.stringify)
把结果填入缓存。此处仅返回本地值。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn set_json_value(&self, value: Value)
pub fn set_json_value(&self, value: Value)
设置缓存的 JSON value(由 B 类 method 填入)。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn get_property(&self, name: &str) -> Option<Rc<JSHandle>>
pub fn get_property(&self, name: &str) -> Option<Rc<JSHandle>>
查询本地缓存 property。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn get_properties(&self) -> Vec<(String, Rc<JSHandle>)>
pub fn get_properties(&self) -> Vec<(String, Rc<JSHandle>)>
列出所有本地缓存 properties。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn set_property(&self, name: impl Into<String>, handle: Rc<JSHandle>)
pub fn set_property(&self, name: impl Into<String>, handle: Rc<JSHandle>)
写入本地缓存 property(B 类 method 填入)。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn dispose(&self)
pub fn dispose(&self)
dispose — 标记本地 + 释放 properties 缓存。
注意:本方法仅清理本地状态;真正调用 Runtime.releaseObject 的 B 类
命令由 Page/Frame 持有的 transport 触发(不在本 D 类方法范围内)。
@trace REQ-BAO-API-006 [class:JSHandle]
Sourcepub fn is_element_handle(&self) -> bool
pub fn is_element_handle(&self) -> bool
是否是 Element 类型。
@trace REQ-BAO-API-006 [class:JSHandle]
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for JSHandle
impl !RefUnwindSafe for JSHandle
impl !Send for JSHandle
impl !Sync for JSHandle
impl !UnwindSafe for JSHandle
impl Unpin for JSHandle
impl UnsafeUnpin for JSHandle
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
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> ⓘ
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> ⓘ
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