pub struct Browser { /* private fields */ }Expand description
Browser 本地状态(高层)。
@trace REQ-BAO-API-006 [class:Browser]
Implementations§
Source§impl Browser
impl Browser
Sourcepub fn new(opts: BrowserOptions) -> Browser
pub fn new(opts: BrowserOptions) -> Browser
构造 Browser(传入 ws_endpoint / 初始 options)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn new_for_test(ws_endpoint: &str) -> Browser
pub fn new_for_test(ws_endpoint: &str) -> Browser
测试构造(简化)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
是否已连接(transport 未关闭)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn set_disconnected(&self)
pub fn set_disconnected(&self)
标记已断开(transport close / disconnected 事件触发)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn ws_endpoint(&self) -> &str
pub fn ws_endpoint(&self) -> &str
WebSocket endpoint。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn set_version(&self, v: impl Into<String>)
pub fn set_version(&self, v: impl Into<String>)
设置 version(Browser.getVersion 响应填入)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn user_agent(&self) -> Option<String>
pub fn user_agent(&self) -> Option<String>
User-Agent(本地缓存)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn set_user_agent(&self, ua: impl Into<String>)
pub fn set_user_agent(&self, ua: impl Into<String>)
设置 user agent。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn contexts(&self) -> Vec<Rc<BrowserContext>>
pub fn contexts(&self) -> Vec<Rc<BrowserContext>>
所有 contexts(克隆)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn context_count(&self) -> usize
pub fn context_count(&self) -> usize
Context 数量。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn disconnect(&self)
pub fn disconnect(&self)
Disconnect — 标记本地断开。
注:本 TASK 仅本地状态。真正调用 transport.close 由调用方在外部封装。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn close(&self)
pub fn close(&self)
Close — 标记断开 + 关闭所有 context + 关闭所有 page。
注:本 TASK 仅本地状态。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn events_inner(&self) -> &Rc<EventEmitterInner>
pub fn events_inner(&self) -> &Rc<EventEmitterInner>
EventEmitter inner 引用。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn has_connection(&self) -> bool
pub fn has_connection(&self) -> bool
是否绑定 Connection(可发送 CDP 命令)。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn set_connection(&self, conn: Rc<RefCell<Connection>>)
pub fn set_connection(&self, conn: Rc<RefCell<Connection>>)
设置 Connection(共享引用)。
Browser 持有 Connection,所有通过此 Browser 创建的 Page 共享同一连接。
@trace REQ-BAO-API-006 [class:Browser]
Sourcepub fn connection(&self) -> Option<Rc<RefCell<Connection>>>
pub fn connection(&self) -> Option<Rc<RefCell<Connection>>>
获取 Connection 的共享引用(若已绑定)。
@trace REQ-BAO-API-006 [class:Browser]
Trait Implementations§
Source§impl EventEmitter for Browser
impl EventEmitter for Browser
Source§fn on(&self, event: &str, handler: Arc<dyn Fn(&[Value])>) -> u64
fn on(&self, event: &str, handler: Arc<dyn Fn(&[Value])>) -> u64
Source§fn off(&self, event: &str, handler_id: u64) -> SubscriptionResult
fn off(&self, event: &str, handler_id: u64) -> SubscriptionResult
Source§fn remove_all_listeners(&self, event: Option<&str>)
fn remove_all_listeners(&self, event: Option<&str>)
event=None 时清空所有事件的所有 handler。Source§fn listener_count(&self, event: &str) -> usize
fn listener_count(&self, event: &str) -> usize
Auto Trait Implementations§
impl !Freeze for Browser
impl !RefUnwindSafe for Browser
impl !Send for Browser
impl !Sync for Browser
impl !UnwindSafe for Browser
impl Unpin for Browser
impl UnsafeUnpin for Browser
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,
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