#[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>) -> Watch
pub fn watch_path(self, path: impl AsRef<Path>) -> Watch
Add a path to watch for changes.
Sourcepub fn watch_paths(
self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Watch
pub fn watch_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Watch
Add multiple paths to watch for changes.
Sourcepub fn exclude_path(self, path: impl AsRef<Path>) -> Watch
pub fn exclude_path(self, path: impl AsRef<Path>) -> Watch
Add a path that will be ignored if changes are detected.
Sourcepub fn exclude_paths(
self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Watch
pub fn exclude_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Watch
Add multiple paths that will be ignored if changes are detected.
Sourcepub fn exclude_workspace_path(self, path: impl AsRef<Path>) -> Watch
pub fn exclude_workspace_path(self, path: impl AsRef<Path>) -> Watch
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>>,
) -> Watch
pub fn exclude_workspace_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Watch
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<Watch, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Watch, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Watch, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Watch, 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.Source§impl Parser for Watch
impl Parser for Watch
Source§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
Source§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
Source§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
Auto Trait Implementations§
impl Freeze for Watch
impl RefUnwindSafe for Watch
impl Send for Watch
impl Sync for Watch
impl Unpin for Watch
impl UnsafeUnpin for Watch
impl UnwindSafe for Watch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more