Stop using Builder for RuntimeConfig
This commit is contained in:
parent
53854d93d4
commit
6c3c06e39c
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
|||
|
||||
use tokio::time::sleep;
|
||||
use watchexec::{
|
||||
config::{InitConfigBuilder, RuntimeConfigBuilder},
|
||||
config::{InitConfigBuilder, RuntimeConfig},
|
||||
Watchexec,
|
||||
};
|
||||
|
||||
|
@ -19,7 +19,7 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
|||
}))
|
||||
.build()?;
|
||||
|
||||
let runtime = RuntimeConfigBuilder::default().build()?;
|
||||
let runtime = RuntimeConfig::default();
|
||||
|
||||
let wx = Watchexec::new(init, runtime)?;
|
||||
wx.main();
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
use std::fmt;
|
||||
use std::{fmt, sync::Arc, time::Duration};
|
||||
|
||||
use atomic_take::AtomicTake;
|
||||
use derive_builder::Builder;
|
||||
|
||||
use crate::{error::RuntimeError, handler::Handler};
|
||||
use crate::{action::Action, error::RuntimeError, handler::Handler};
|
||||
|
||||
/// Runtime configuration for [`Watchexec`][crate::Watchexec].
|
||||
///
|
||||
/// This is used both when constructing the instance (as initial configuration) and to reconfigure
|
||||
/// it at runtime via [`Watchexec::reconfig()`][crate::Watchexec::reconfig()].
|
||||
///
|
||||
/// Use [`RuntimeConfigBuilder`] to build a new one, or modify an existing one. This struct is
|
||||
/// marked non-exhaustive such that new options may be added without breaking change.
|
||||
#[derive(Builder, Clone, Debug)]
|
||||
/// Use [`RuntimeConfig::default()`] to build a new one, or modify an existing one. This struct is
|
||||
/// marked non-exhaustive such that new options may be added without breaking change. You can make
|
||||
/// changes through the fields directly, or use the convenience (chainable!) methods instead.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct RuntimeConfig {
|
||||
/// Working data for the filesystem event source.
|
||||
///
|
||||
/// This notably includes the path set to be watched.
|
||||
#[builder(default)]
|
||||
pub fs: crate::fs::WorkingData,
|
||||
|
||||
/// Working data for the action processing.
|
||||
///
|
||||
/// This is the task responsible for scheduling the actions in response to events, applying the
|
||||
/// filtering, etc.
|
||||
#[builder(default)]
|
||||
pub action: crate::action::WorkingData,
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
//! let init = InitConfigBuilder::default()
|
||||
//! .error_handler(PrintDebug(std::io::stderr()));
|
||||
//!
|
||||
//! let mut runtime = RuntimeConfigBuilder::default()
|
||||
//! config.pathset(["watchexec.conf"]);
|
||||
//! let mut runtime = RuntimeConfig::default()
|
||||
//! runtime.pathset(["watchexec.conf"]);
|
||||
//!
|
||||
//! let conf = YourConfigFormat::load_from_file("watchexec.conf").await?;
|
||||
//! conf.apply(&mut runtime);
|
||||
//!
|
||||
//! let we = Watchexec::new(init.build().unwrap(), runtime.build().unwrap()).unwrap();
|
||||
//! let we = Watchexec::new(init.build().unwrap(), runtime.clone()).unwrap();
|
||||
//! let w = we.clone();
|
||||
//!
|
||||
//! let c = config.clone();
|
||||
|
@ -34,7 +34,7 @@
|
|||
//! let conf = YourConfigFormat::load_from_file("watchexec.conf").await?;
|
||||
//!
|
||||
//! conf.apply(&mut runtime);
|
||||
//! w.reconfigure(runtime.build().unwrap());
|
||||
//! w.reconfigure(runtime.clone());
|
||||
//! // tada! self-reconfiguring watchexec on config file change!
|
||||
//! }
|
||||
//! });
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
|||
|
||||
use tokio::time::sleep;
|
||||
use watchexec::{
|
||||
config::{InitConfigBuilder, RuntimeConfigBuilder},
|
||||
config::{InitConfigBuilder, RuntimeConfig},
|
||||
Watchexec,
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,7 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
|||
}))
|
||||
.build()?;
|
||||
|
||||
let runtime = RuntimeConfigBuilder::default().build()?;
|
||||
let runtime = RuntimeConfig::default();
|
||||
|
||||
let wx = Watchexec::new(init, runtime)?;
|
||||
wx.main();
|
||||
|
|
Loading…
Reference in New Issue