pub struct Worker<T> { /* private fields */ }Expand description
Represents a generic Worker that can be in many different states
Implementations§
Source§impl<S, P> Worker<Ready<S, P>>
impl<S, P> Worker<Ready<S, P>>
Sourcepub fn on_event<F: Fn(Worker<Event>) + Send + Sync + 'static>(
self,
f: F,
) -> Self
pub fn on_event<F: Fn(Worker<Event>) + Send + Sync + 'static>( self, f: F, ) -> Self
Add an event handler to the worker
Sourcepub fn run<Req, Res, Ctx>(self) -> Runnable ⓘwhere
S: Service<Request<Req, Ctx>, Response = Res> + Send + 'static,
P: Backend<Request<Req, Ctx>, Res> + 'static,
Req: Send + 'static + Sync,
S::Future: Send,
S::Response: 'static + Send + Sync + Serialize,
S::Error: Send + Sync + 'static + Into<BoxDynError>,
P::Stream: Unpin + Send + 'static,
P::Layer: Layer<S>,
<P::Layer as Layer<S>>::Service: Service<Request<Req, Ctx>, Response = Res> + Send,
<<P::Layer as Layer<S>>::Service as Service<Request<Req, Ctx>>>::Future: Send,
<<P::Layer as Layer<S>>::Service as Service<Request<Req, Ctx>>>::Error: Send + Into<BoxDynError> + Sync,
Ctx: Send + 'static + Sync,
Res: 'static,
pub fn run<Req, Res, Ctx>(self) -> Runnable ⓘwhere
S: Service<Request<Req, Ctx>, Response = Res> + Send + 'static,
P: Backend<Request<Req, Ctx>, Res> + 'static,
Req: Send + 'static + Sync,
S::Future: Send,
S::Response: 'static + Send + Sync + Serialize,
S::Error: Send + Sync + 'static + Into<BoxDynError>,
P::Stream: Unpin + Send + 'static,
P::Layer: Layer<S>,
<P::Layer as Layer<S>>::Service: Service<Request<Req, Ctx>, Response = Res> + Send,
<<P::Layer as Layer<S>>::Service as Service<Request<Req, Ctx>>>::Future: Send,
<<P::Layer as Layer<S>>::Service as Service<Request<Req, Ctx>>>::Error: Send + Into<BoxDynError> + Sync,
Ctx: Send + 'static + Sync,
Res: 'static,
Start a worker
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Worker<T>where
T: Freeze,
impl<T> RefUnwindSafe for Worker<T>where
T: RefUnwindSafe,
impl<T> Send for Worker<T>where
T: Send,
impl<T> Sync for Worker<T>where
T: Sync,
impl<T> Unpin for Worker<T>where
T: Unpin,
impl<T> UnwindSafe for Worker<T>where
T: UnwindSafe,
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