pub struct Worker {
inner: Weak<Worker>,
}Expand description
The Worker class represents a WebWorker. worker
event is emitted on the page object to signal a worker creation. close event is emitted on the worker object when the
worker is gone.
page.on('worker', worker => {
console.log('Worker created: ' + worker.url());
worker.on('close', worker => console.log('Worker destroyed: ' + worker.url()));
});
console.log('Current workers:');
for (const worker of page.workers())
console.log(' ' + worker.url());Fields§
§inner: Weak<Worker>Implementations§
Source§impl Worker
impl Worker
pub(crate) fn new(inner: Weak<Impl>) -> Self
pub fn url(&self) -> Result<String, Error>
pub async fn eval_handle( &self, expression: &str, ) -> Result<JsHandle, Arc<Error>>
pub async fn evaluate_handle<T>(
&self,
expression: &str,
arg: Option<T>,
) -> Result<JsHandle, Arc<Error>>where
T: Serialize,
pub async fn eval<U>(&self, expression: &str) -> Result<U, Arc<Error>>where
U: DeserializeOwned,
pub async fn evaluate<T, U>(
&self,
expression: &str,
arg: Option<T>,
) -> Result<U, Arc<Error>>where
T: Serialize,
U: DeserializeOwned,
pub fn subscribe_event( &self, ) -> Result<impl Stream<Item = Result<Event, BroadcastStreamRecvError>>, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Worker
impl RefUnwindSafe for Worker
impl Send for Worker
impl Sync for Worker
impl Unpin for Worker
impl UnwindSafe for Worker
Blanket Implementations§
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