#[non_exhaustive]pub struct Watch {
pub shell_commands: Vec<String>,
pub cargo_commands: Vec<String>,
pub watch_paths: Vec<PathBuf>,
pub exclude_paths: Vec<PathBuf>,
pub workspace_exclude_paths: Vec<PathBuf>,
pub debounce: Duration,
/* private fields */
}Expand description
Watches over your project’s source code, relaunching a given command when changes are detected.
Use Watch::lock to obtain a WatchLock that can be shared with external
code (e.g. an HTTP server) to coordinate reads with ongoing rebuilds.
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.shell_commands: Vec<String>Shell command(s) to execute on changes.
cargo_commands: Vec<String>Cargo command(s) to execute on changes.
The default is [ check ]
watch_paths: Vec<PathBuf>Watch specific file(s) or folder(s).
The default is the workspace root.
exclude_paths: Vec<PathBuf>Paths or glob patterns that will be excluded.
Relative values are resolved from the current working directory.
workspace_exclude_paths: Vec<PathBuf>Paths or glob patterns, relative to the workspace root, that will be excluded.
debounce: DurationThrottle events to prevent the command to be re-executed too early right after an execution already occurred.
The default is 2 seconds.
Implementations§
Source§impl Watch
impl Watch
Sourcepub fn watch_path(self, path: impl AsRef<Path>) -> Self
pub fn watch_path(self, path: impl AsRef<Path>) -> Self
Add a path to watch for changes.
Sourcepub fn watch_paths(
self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Self
pub fn watch_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self
Add multiple paths to watch for changes.
Sourcepub fn exclude_path(self, path: impl AsRef<Path>) -> Self
pub fn exclude_path(self, path: impl AsRef<Path>) -> Self
Add a path that will be ignored if changes are detected.
Sourcepub fn exclude_paths(
self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Self
pub fn exclude_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self
Add multiple paths that will be ignored if changes are detected.
Sourcepub fn exclude_workspace_path(self, path: impl AsRef<Path>) -> Self
pub fn exclude_workspace_path(self, path: impl AsRef<Path>) -> Self
Add a path, relative to the workspace, that will be ignored if changes are detected.
Sourcepub fn exclude_workspace_paths(
self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Self
pub fn exclude_workspace_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self
Add multiple paths, relative to the workspace, that will be ignored if changes are detected.
Sourcepub fn lock(&self) -> WatchLock
pub fn lock(&self) -> WatchLock
Return the shared lock used by this watcher.
Clone and share this lock with external code (e.g. HTTP handlers) to coordinate with watch-driven command execution.
§Lock lifecycle
run acquires the write lock immediately when it is called — before the
first command is even spawned. Any code that calls WatchLock::acquire will therefore
block until the first build completes. This is intentional: it prevents readers from
observing an empty or incomplete dist directory before the initial build has finished.
The write lock is then re-acquired on every subsequent rebuild and released once the
command sequence succeeds.
Trait Implementations§
Source§impl Args for Watch
impl Args for Watch
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl CommandFactory for Watch
impl CommandFactory for Watch
Source§impl FromArgMatches for Watch
impl FromArgMatches for Watch
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.