pub struct Worker { /* private fields */ }Expand description
Auto-generated bindings for an instance a component which
implements the world worker.
This structure can be created through a number of means depending on your requirements and what you have on hand:
-
The most convenient way is to use
Worker::instantiate_asyncwhich only needs aStore,Component, andLinker. -
Alternatively you can create a
WorkerPreahead of time with aComponentto front-load string lookups of exports once instead of per-instantiation. This method then usesWorkerPre::instantiate_asyncto create aWorker. -
If you’ve instantiated the instance yourself already then you can use
Worker::new.
These methods are all equivalent to one another and move around the tradeoff of what work is performed when.
Implementations§
Source§impl Worker
impl Worker
Sourcepub async fn instantiate_async<_T>(
store: impl AsContextMut<Data = _T>,
component: &Component,
linker: &Linker<_T>,
) -> Result<Worker>where
_T: Send,
pub async fn instantiate_async<_T>(
store: impl AsContextMut<Data = _T>,
component: &Component,
linker: &Linker<_T>,
) -> Result<Worker>where
_T: Send,
Convenience wrapper around WorkerPre::new and
WorkerPre::instantiate_async.
Sourcepub fn new(store: impl AsContextMut, instance: &Instance) -> Result<Worker>
pub fn new(store: impl AsContextMut, instance: &Instance) -> Result<Worker>
Convenience wrapper around WorkerIndices::new and
WorkerIndices::load.
pub fn add_to_linker<T, D>( linker: &mut Linker<T>, host_getter: fn(&mut T) -> D::Data<'_>, ) -> Result<()>
pub async fn call_init<S: AsContextMut>( &self, store: S, arg0: &Config, ) -> Result<()>
pub async fn call_handle<S: AsContextMut>( &self, store: S, arg0: u32, arg1: &Event, ) -> Result<Result<Response, HandleError>>
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request