pub struct SharedWorkerChannelBridge {
pub shared_worker_id: SharedWorkerId,
pub port_channels: Vec<SharedWorkerPortChannel>,
}Expand description
Aggregated channel bridge for a SharedWorker across all connected pages.
Unlike DedicatedWorker (which has a single channel bridge), SharedWorker has N port channels (one per connected page). This struct aggregates all port channels for a single SharedWorker and provides unified drain across all ports.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Fields§
SharedWorker ID this bridge belongs to. @trace REQ-BRW-004 [entity:SharedWorker]
port_channels: Vec<SharedWorkerPortChannel>Per-page port channels keyed by a port index. Each page has its own MessagePort with independent send/receive. @trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Implementations§
Sourcepub fn new(shared_worker_id: SharedWorkerId) -> Self
pub fn new(shared_worker_id: SharedWorkerId) -> Self
Create a new channel bridge for the given SharedWorker.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Sourcepub fn add_port(&mut self) -> SharedWorkerPortEndpoints
pub fn add_port(&mut self) -> SharedWorkerPortEndpoints
Add a new port channel for a newly connecting page.
Returns the port endpoints for the worker thread’s use.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Sourcepub fn drain_all_worker_messages(
&self,
) -> (Vec<WorkerStructuredMessage>, Vec<SharedWorkerId>)
pub fn drain_all_worker_messages( &self, ) -> (Vec<WorkerStructuredMessage>, Vec<SharedWorkerId>)
Drain all pending worker→page messages from all ports (DF-WK-7).
Called during spin_event_loop to process all queued messages from the SharedWorker across all connected pages. Returns messages and any disconnected SharedWorkerIds.
@trace REQ-BRW-004 [entity:SharedWorkerGlobalScope] DF-WK-7 @trace REQ-BRW-004 [criterion:18] crash-safe teardown detection
Sourcepub fn remove_disconnected_ports(&mut self)
pub fn remove_disconnected_ports(&mut self)
Remove port channels that have been disconnected.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
Sourcepub fn port_count(&self) -> usize
pub fn port_count(&self) -> usize
Returns the number of connected port channels.
@trace REQ-BRW-004 [entity:SharedWorker]
Sourcepub fn post_to_worker_from_port(
&self,
port_index: usize,
payload: StructuredClonePayload,
) -> Result<(), String>
pub fn post_to_worker_from_port( &self, port_index: usize, payload: StructuredClonePayload, ) -> Result<(), String>
Post a message from a specific page (by port index) to the SharedWorker.
@trace REQ-BRW-004 [entity:SharedWorker] DF-WK-7
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