logo
#[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
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.
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: usize

Internal: 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: usize

Internal: 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

Set the runtime error handler.

See the documentation on the field for more details.

Set the buffer size of the channel which carries runtime errors.

See the documentation on the field for more details.

Set the buffer size of the channel which carries events.

See the documentation on the field for more details.

Trait Implementations

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 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