Rename Config to Parallax
A config is the Fennel file; a Parallax is the loaded, executable
instance of one.
Assisted-by: GLM-5.3 via pi
diff --git a/src/lib.rs b/src/lib.rs
index ddcda0c..5c7c7a7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,9 +1,9 @@
-mod config;
mod error;
+mod parallax;
mod run;
mod validate;
-pub use config::Config;
pub use error::Error;
+pub use parallax::Parallax;
pub use run::list;
pub use run::run;
diff --git a/src/config.rs b/src/parallax.rs
similarity index 93%
rename from src/config.rs
rename to src/parallax.rs
index 41ceefc..6359790 100644
--- a/src/config.rs
+++ b/src/parallax.rs
@@ -20,10 +20,11 @@ struct Flow {
call: Function,
}
-/// A loaded config, parsed into typed fields. The functions are owned
-/// handles into the embedded Lua state, which stays alive in this
-/// struct; fields are ordered so the handles drop while the VM lives.
-pub struct Config {
+/// A loaded parallax: the executable form of a config. The flows and
+/// baseline are owned handles into the embedded Lua state, which stays
+/// alive in this struct; fields are ordered so the handles drop while
+/// the VM lives.
+pub struct Parallax {
flows: Vec<Flow>,
// The fields below are consumed once running configs lands: the
// baseline function gets called with the cache directory, the
@@ -40,15 +41,15 @@ pub struct Config {
lua: Lua,
}
-impl Config {
- pub fn load(path: &Path) -> Result<Config, Error> {
+impl Parallax {
+ pub fn load(path: &Path) -> Result<Parallax, Error> {
let source = fs_err::read_to_string(path)?;
// The Fennel compiler requires the debug library, which mlua's
// safe default omits. Configs are the user's own trusted files,
// so the full stdlib is fine here.
let lua = unsafe { Lua::unsafe_new() };
let table = load_table(&lua, path, &source)?;
- build_config(lua, &table, path)
+ build(lua, &table, path)
}
pub fn flow_names(&self) -> Vec<String> {
@@ -64,10 +65,10 @@ impl Config {
}
}
-/// Re-parses the validated table into the typed fields and extracts the
+/// Parses the validated table into the typed fields and extracts the
/// function handles serde can't carry. Validation already ran inside
/// the parallax call, so failures here are internal errors.
-fn build_config(lua: Lua, table: &Table, path: &Path) -> Result<Config, Error> {
+fn build(lua: Lua, table: &Table, path: &Path) -> Result<Parallax, Error> {
let fail = |error: mlua::Error| Error::Config {
path: path.to_path_buf(),
error,
@@ -91,7 +92,7 @@ fn build_config(lua: Lua, table: &Table, path: &Path) -> Result<Config, Error> {
let name = schema.name.clone().unwrap_or_else(|| default_name(path));
- Ok(Config {
+ Ok(Parallax {
flows,
baseline,
schema,
diff --git a/src/run.rs b/src/run.rs
index b6437ab..14f933e 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -1,17 +1,17 @@
use std::path::Path;
-use crate::Config;
use crate::Error;
+use crate::Parallax;
pub fn list(path: &Path) -> Result<(), Error> {
- let config = Config::load(path)?;
- for name in config.flow_names() {
+ let parallax = Parallax::load(path)?;
+ for name in parallax.flow_names() {
println!("{name}");
}
Ok(())
}
pub async fn run(path: &Path, _output: Option<&Path>) -> Result<(), Error> {
- Config::load(path)?;
+ Parallax::load(path)?;
Err(Error::NotImplemented)
}