#[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§

source§

impl InitConfig

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Debug for InitConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for InitConfig

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more