Struct ora_test::TestWorker
source · pub struct TestWorker { /* private fields */ }
Expand description
A worker that can be used to test worker implementations.
Implementations§
source§impl TestWorker
impl TestWorker
sourcepub fn register_worker(
&mut self,
worker: Arc<dyn RawHandler + Send + Sync>
) -> &mut Self
pub fn register_worker( &mut self, worker: Arc<dyn RawHandler + Send + Sync> ) -> &mut Self
Add a handler to the test worker.
Panics
Panics if a worker with a matching WorkerSelector
already exists.
sourcepub fn spawn_task<T>(
&mut self,
task: TaskDefinition<T>
) -> Option<TaskHandle<T>>where
T: Send + 'static,
pub fn spawn_task<T>( &mut self, task: TaskDefinition<T> ) -> Option<TaskHandle<T>>where T: Send + 'static,
Spawn a task onto the worker, immediately run it with a
registered and return a TaskHandle
for it.
It returns None
if there are no suitable workers registered.
Panics
Panics if not called inside a tokio
runtime.
Trait Implementations§
source§impl Debug for TestWorker
impl Debug for TestWorker
source§impl Default for TestWorker
impl Default for TestWorker
source§fn default() -> TestWorker
fn default() -> TestWorker
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for TestWorker
impl Send for TestWorker
impl Sync for TestWorker
impl Unpin for TestWorker
impl !UnwindSafe for TestWorker
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
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<W> IntoHandler for Wwhere
W: Send + Sync + 'static,
impl<W> IntoHandler for Wwhere W: Send + Sync + 'static,
source§fn handler<T>(self) -> Arc<dyn RawHandler + Sync + Send, Global>where
Self: Handler<T>,
T: Task,
fn handler<T>(self) -> Arc<dyn RawHandler + Sync + Send, Global>where Self: Handler<T>, T: Task,
Convert
self
into a RawHandler
that can be registered
in workers.source§fn handler_with_selector<T>(
self,
selector: WorkerSelector
) -> Arc<dyn RawHandler + Sync + Send, Global>where
Self: Handler<T>,
T: Task,
fn handler_with_selector<T>( self, selector: WorkerSelector ) -> Arc<dyn RawHandler + Sync + Send, Global>where Self: Handler<T>, T: Task,
Convert
self
into a RawHandler
that can be registered
in workers with the given selector.