logo
#[non_exhaustive]
pub struct WorkingData { pub throttle: Duration, pub action_handler: HandlerLock<Action>, pub pre_spawn_handler: HandlerLock<PreSpawn>, pub post_spawn_handler: HandlerLock<PostSpawn>, pub commands: Vec<Command>, pub grouped: bool, pub filterer: Arc<dyn Filterer>, }
Expand description

The configuration of the action worker.

This is marked non-exhaustive so new configuration can be added without breaking.

Fields (Non-exhaustive)

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
throttle: Duration

How long to wait for events to build up before executing an action.

This is sometimes called “debouncing.” We debounce on the trailing edge: an action is triggered only after that amount of time has passed since the first event in the cycle. The action is called with all the collected events in the cycle.

action_handler: HandlerLock<Action>

The main handler to define: what to do when an action is triggered.

This handler is called with the Action environment, which has a certain way of returning the desired outcome, check out the Action::outcome() method. The handler checks for the outcome as soon as the handler returns, which means that if the handler returns before the outcome is set, you’ll get unexpected results. For this reason, it’s a bad idea to use ex. a channel as the handler.

If this handler is not provided, it defaults to a no-op, which does absolutely nothing, not even quit. Hence, you really need to provide a handler.

It is possible to change the handler or any other configuration inside the previous handler. It’s useful to know that the handlers are updated from this working data before any of them run in any given cycle, so changing the pre-spawn and post-spawn handlers from this handler will not affect the running action.

pre_spawn_handler: HandlerLock<PreSpawn>

A handler triggered before a command is spawned.

This handler is called with the PreSpawn environment, which provides mutable access to the Command which is about to be run. See the notes on the PreSpawn::command() method for important information on what you can do with it.

Returning an error from the handler will stop the action from processing further, and issue a RuntimeError to the error channel.

post_spawn_handler: HandlerLock<PostSpawn>

A handler triggered immediately after a command is spawned.

This handler is called with the PostSpawn environment, which provides details on the spawned command, including its PID.

Returning an error from the handler will drop the Child, which will terminate the command without triggering any of the normal Watchexec behaviour, and issue a RuntimeError to the error channel.

commands: Vec<Command>

Commands to execute.

These will be run in order, and an error will stop early.

grouped: bool

Whether to use process groups (on Unix) or job control (on Windows) to run the command.

This makes use of command_group under the hood.

If you want to known whether a spawned command was run in a process group, you should use the value in PostSpawn instead of reading this one, as it may have changed in the meantime.

filterer: Arc<dyn Filterer>

The filterer implementation to use when filtering events.

The default is a no-op, which will always pass every event.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more