pub struct SharedWorkerPortChannel {
pub shared_worker_id: SharedWorkerId,
pub page_to_worker_tx: Sender<StructuredClonePayload>,
pub worker_to_page_rx: Receiver<WorkerStructuredMessage>,
}Expand description
A per-page MessagePort channel for a SharedWorker.
Each page that connects to a SharedWorker gets its own MessagePort channel pair (DF-WK-7: “connect 事件派发 MessagePort → 各页经独立 port 通信”). This struct holds the bao-side channel endpoints for a single page’s connection to a SharedWorker.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Fields§
The SharedWorker this port connects to. @trace REQ-BRW-004 [entity:SharedWorker]
page_to_worker_tx: Sender<StructuredClonePayload>Sender for page→worker messages via this port (DF-WK-7). @trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
worker_to_page_rx: Receiver<WorkerStructuredMessage>Receiver for worker→page messages via this port (DF-WK-7). @trace REQ-BRW-004 [entity:SharedWorkerGlobalScope] DF-WK-7
Implementations§
Sourcepub fn new(
shared_worker_id: SharedWorkerId,
) -> (Self, SharedWorkerPortEndpoints)
pub fn new( shared_worker_id: SharedWorkerId, ) -> (Self, SharedWorkerPortEndpoints)
Create a new port channel for a SharedWorker connection.
Returns the port channel (kept by bao_browser per-page) and a
SharedWorkerPortEndpoints for the worker thread’s use.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Sourcepub fn post_message_to_worker(
&self,
payload: StructuredClonePayload,
) -> Result<(), SendError<StructuredClonePayload>>
pub fn post_message_to_worker( &self, payload: StructuredClonePayload, ) -> Result<(), SendError<StructuredClonePayload>>
Post a message from this page to the SharedWorker (DF-WK-7).
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Sourcepub fn try_recv_from_worker(
&self,
) -> Result<Option<WorkerStructuredMessage>, ()>
pub fn try_recv_from_worker( &self, ) -> Result<Option<WorkerStructuredMessage>, ()>
Try to receive a message from the SharedWorker (DF-WK-7).
@trace REQ-BRW-004 [entity:SharedWorkerGlobalScope] DF-WK-7
Sourcepub fn drain_worker_messages(&self) -> WorkerDrainResult
pub fn drain_worker_messages(&self) -> WorkerDrainResult
Drain all pending worker→page messages from this port (DF-WK-7).
Returns a WorkerDrainResult with messages and disconnected flag.
@trace REQ-BRW-004 [entity:SharedWorkerGlobalScope] DF-WK-7
@trace REQ-BRW-004 [criterion:18] crash-safe teardown detection
Trait Implementations§
Auto Trait Implementations§
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