pub struct Worker<I: IpcValue, O: IpcValue> { /* private fields */ }Expand description
Represents a running worker process.
Implementations§
Source§impl<I: IpcValue, O: IpcValue> Worker<I, O>
impl<I: IpcValue, O: IpcValue> Worker<I, O>
Sourcepub async fn start(worker_name: impl Into<Txt>) -> Result<Self>
pub async fn start(worker_name: impl Into<Txt>) -> Result<Self>
Start a worker process implemented in the current executable.
Note that the current process must call run_worker at startup to actually work.
You can use zng_env::on_process_start! to inject startup code.
Sourcepub async fn start_with(
worker_name: impl Into<Txt>,
env_vars: &[(&str, &str)],
args: &[&str],
) -> Result<Self>
pub async fn start_with( worker_name: impl Into<Txt>, env_vars: &[(&str, &str)], args: &[&str], ) -> Result<Self>
Start a worker process implemented in the current executable with custom env vars and args.
Sourcepub async fn start_other(
worker_name: impl Into<Txt>,
worker_exe: impl Into<PathBuf>,
env_vars: &[(&str, &str)],
args: &[&str],
) -> Result<Self>
pub async fn start_other( worker_name: impl Into<Txt>, worker_exe: impl Into<PathBuf>, env_vars: &[(&str, &str)], args: &[&str], ) -> Result<Self>
Start a worker process implemented in another executable with custom env vars and args.
Sourcepub fn run(
&mut self,
input: I,
) -> impl Future<Output = Result<O, RunError>> + Send + 'static
pub fn run( &mut self, input: I, ) -> impl Future<Output = Result<O, RunError>> + Send + 'static
Run a task in a free worker process thread.
Sourcepub fn crash_error(&mut self) -> Option<&WorkerCrashError>
pub fn crash_error(&mut self) -> Option<&WorkerCrashError>
Reference the crash error.
The worker cannot be used if this is set, run requests will immediately disconnect.
Trait Implementations§
Auto Trait Implementations§
impl<I, O> Freeze for Worker<I, O>
impl<I, O> !RefUnwindSafe for Worker<I, O>
impl<I, O> Send for Worker<I, O>
impl<I, O> Sync for Worker<I, O>where
I: Sync,
impl<I, O> Unpin for Worker<I, O>where
I: Unpin,
impl<I, O> !UnwindSafe for Worker<I, O>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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