Struct watchexec::config::InitConfig
source · #[non_exhaustive]pub struct InitConfig {
pub error_handler: Box<dyn Handler<ErrorHook> + Send>,
pub error_channel_size: usize,
pub event_channel_size: usize,
}Expand description
Initialisation configuration for Watchexec.
This is used only for constructing the instance.
Use InitConfig::default() to build a new one, and the inherent methods to change values.
This struct is marked non-exhaustive such that new options may be added without breaking change.
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.error_handler: Box<dyn Handler<ErrorHook> + Send>Runtime error handler.
This is run on every runtime error that occurs within watchexec. By default the placeholder
() handler is used, which discards all errors.
If the handler errors, that error is immediately given to the handler. If this second handler call errors as well, its error is ignored.
Also see the ErrorHook documentation for returning critical errors from this handler.
Examples
let mut init = InitConfig::default();
init.on_error(|err: ErrorHook| async move {
tracing::error!("{}", err.error);
Ok::<(), Infallible>(())
});error_channel_size: usizeInternal: the buffer size of the channel which carries runtime errors.
The default (64) is usually fine. If you expect a much larger throughput of runtime errors,
or if your error_handler is slow, adjusting this value may help.
event_channel_size: usizeInternal: the buffer size of the channel which carries events.
The default (1024) is usually fine. If you expect a much larger throughput of events, adjusting this value may help.
Implementations§
source§impl InitConfig
impl InitConfig
sourcepub fn on_error(
&mut self,
handler: impl Handler<ErrorHook> + Send + 'static
) -> &mut Self
pub fn on_error( &mut self, handler: impl Handler<ErrorHook> + Send + 'static ) -> &mut Self
Set the runtime error handler.
See the documentation on the field for more details.
sourcepub fn error_channel_size(&mut self, size: usize) -> &mut Self
pub fn error_channel_size(&mut self, size: usize) -> &mut Self
Set the buffer size of the channel which carries runtime errors.
See the documentation on the field for more details.
sourcepub fn event_channel_size(&mut self, size: usize) -> &mut Self
pub fn event_channel_size(&mut self, size: usize) -> &mut Self
Set the buffer size of the channel which carries events.
See the documentation on the field for more details.