pub struct WebSocketTransport { /* private fields */ }Expand description
WebSocketTransport — 外部 Chrome CDP 客户端模式。
包装 bun_uws::ws_client::WebSocketClient。Transport trait 接口不变。
@trace REQ-BAO-API-002 [interface:Transport] @trace REQ-CDP-UWS-001
Implementations§
Source§impl WebSocketTransport
impl WebSocketTransport
Sourcepub fn connect(url: &str) -> Result<WebSocketTransport, CdpError>
pub fn connect(url: &str) -> Result<WebSocketTransport, CdpError>
连接到 WebSocket CDP endpoint。
url 必须是 ws://host:port/path 形式(wss:// TLS 后续 TASK 增加)。
§错误
CdpError::HandshakeError:URL 格式错误 / 握手失败CdpError::IoError:TCP 连接失败
@trace REQ-BAO-API-002 [interface:Transport]
Sourcepub fn connect_on_stream(
stream: TcpStream,
host: &str,
path: &str,
) -> Result<WebSocketTransport, CdpError>
pub fn connect_on_stream( stream: TcpStream, host: &str, path: &str, ) -> Result<WebSocketTransport, CdpError>
用已建立的 TcpStream 完成 handshake 并包装。
主要用于测试(mock server 跑在本地端口)。
@trace REQ-BAO-API-002 [interface:Transport]
Sourcepub fn current_id(&self) -> u64
pub fn current_id(&self) -> u64
当前 next id(测试断言用)。
Trait Implementations§
Source§impl Debug for WebSocketTransport
impl Debug for WebSocketTransport
Source§impl Transport for WebSocketTransport
impl Transport for WebSocketTransport
Source§fn kind(&self) -> TransportKind
fn kind(&self) -> TransportKind
返回 transport 类型标识。
Source§fn send_command(
&mut self,
method: &str,
params: Value,
session_id: Option<&str>,
) -> Result<Value, CdpError>
fn send_command( &mut self, method: &str, params: Value, session_id: Option<&str>, ) -> Result<Value, CdpError>
发送 CDP 命令,阻塞等待响应。 Read more
Source§fn recv_event(&mut self) -> Result<Option<CdpEvent>, CdpError>
fn recv_event(&mut self) -> Result<Option<CdpEvent>, CdpError>
接收服务器推送事件,阻塞直到事件到达或超时。 Read more
Source§fn set_command_timeout(&mut self, timeout: Duration)
fn set_command_timeout(&mut self, timeout: Duration)
设置默认命令超时。 Read more
Source§fn set_event_timeout(&mut self, timeout: Duration)
fn set_event_timeout(&mut self, timeout: Duration)
设置默认事件接收超时。 Read more
Auto Trait Implementations§
impl Freeze for WebSocketTransport
impl RefUnwindSafe for WebSocketTransport
impl Send for WebSocketTransport
impl Sync for WebSocketTransport
impl Unpin for WebSocketTransport
impl UnsafeUnpin for WebSocketTransport
impl UnwindSafe for WebSocketTransport
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
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
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>
Creates a filterable data provider with the given name for debugging. Read more
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert