Struct watchexec::action::WorkingData
source · [−]#[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 command: Vec<String>,
pub grouped: bool,
pub shell: Shell,
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
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.
command: Vec<String>
Command to execute.
When shell
is Shell::None
, this is expected to be in “execvp(3)” format: first
program, rest arguments. Otherwise, all elements will be joined together with a single space
and passed to the shell. More control can then be obtained by providing a 1-element vec, and
doing your own joining and/or escaping there.
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.
shell: Shell
The shell to use to run the command.
See the Shell
enum documentation for more details.
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
Auto Trait Implementations
impl !RefUnwindSafe for WorkingData
impl Send for WorkingData
impl Sync for WorkingData
impl Unpin for WorkingData
impl !UnwindSafe for WorkingData
Blanket Implementations
Mutably borrows from an owned value. Read more
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