pub struct WorkerCommand {
pub executable: PathBuf,
pub args: Vec<OsString>,
pub deadline: Duration,
pub canary_deadline: Duration,
}Expand description
How to launch the worker: the executable (usually the app itself, which
calls run_if_requested) plus the selecting argument.
Fields§
§executable: PathBuf§args: Vec<OsString>§deadline: DurationDeadline for one recognition run.
canary_deadline: DurationDeadline for one canary run, separate from deadline. Defaults to WORKER_DEADLINE,
so behavior is unchanged until a host sets it. A canary that gets only the budget left
after the request, as ViewRight does, can use WorkerCommand::with_canary_deadline to
give the check its own bound instead.
Implementations§
Source§impl WorkerCommand
impl WorkerCommand
Sourcepub fn current_exe(arg: &str) -> Result<Self, String>
pub fn current_exe(arg: &str) -> Result<Self, String>
Re-invoke the current executable with arg (the ViewRight shape).
pub fn new<I, S>(executable: impl Into<PathBuf>, args: I) -> Self
Sourcepub fn with_deadline(self, deadline: Duration) -> Self
pub fn with_deadline(self, deadline: Duration) -> Self
Set the deadline for one recognition run.
Sourcepub fn with_canary_deadline(self, deadline: Duration) -> Self
pub fn with_canary_deadline(self, deadline: Duration) -> Self
Set the deadline for canary runs, independently of WorkerCommand::with_deadline.
Sourcepub fn for_canary(&self) -> Self
pub fn for_canary(&self) -> Self
This command with its deadline replaced by WorkerCommand::canary_deadline. Use it for
canary requests (the embedded known-text PNG) so they get their own bound.
Sourcepub fn run(&self, bytes: &[u8]) -> Result<Vec<OcrLine>, String>
pub fn run(&self, bytes: &[u8]) -> Result<Vec<OcrLine>, String>
One isolated recognition request in a fresh child.
Sourcepub fn run_observed(
&self,
bytes: &[u8],
events: &dyn WorkerEvents,
) -> Result<WorkerRun, WorkerFailure>
pub fn run_observed( &self, bytes: &[u8], events: &dyn WorkerEvents, ) -> Result<WorkerRun, WorkerFailure>
One isolated recognition request in a fresh child, reporting lifecycle events to events
as they happen and returning a RunRecord with the same facts.
Use WorkerCommand::run when neither is needed; its behavior and messages are unchanged.