Skip to main content

WorkerCommand

Struct WorkerCommand 

Source
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: Duration

Deadline for one recognition run.

§canary_deadline: Duration

Deadline 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

Source

pub fn current_exe(arg: &str) -> Result<Self, String>

Re-invoke the current executable with arg (the ViewRight shape).

Source

pub fn new<I, S>(executable: impl Into<PathBuf>, args: I) -> Self
where I: IntoIterator<Item = S>, S: Into<OsString>,

Source

pub fn with_deadline(self, deadline: Duration) -> Self

Set the deadline for one recognition run.

Source

pub fn with_canary_deadline(self, deadline: Duration) -> Self

Set the deadline for canary runs, independently of WorkerCommand::with_deadline.

Source

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.

Source

pub fn run(&self, bytes: &[u8]) -> Result<Vec<OcrLine>, String>

One isolated recognition request in a fresh child.

Source

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.

Trait Implementations§

Source§

impl Clone for WorkerCommand

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkerCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.