Skip to main content

vespertide_loader/
lib.rs

1//! Filesystem loading of vespertide models and migrations.
2//!
3//! Supports both JSON and YAML model/migration files. Used by both the CLI
4//! at runtime and the `vespertide_migration!` macro at compile time.
5
6// Test-only env mutation in `migrations.rs` / `models.rs` uses
7// `std::env::set_var` / `remove_var`, which became `unsafe` in Rust 2024.
8// All sites are serialized via `serial_test::serial`, so expect unsafe in tests only.
9#![cfg_attr(
10    test,
11    expect(
12        unsafe_code,
13        reason = "serial_test serializes Rust 2024 std::env var setters used by loader tests"
14    )
15)]
16
17pub mod config;
18pub mod migrations;
19pub mod models;
20mod parallel_config;
21#[cfg(test)]
22mod test_support;
23
24pub use config::{load_config, load_config_from_path, load_config_or_default};
25
26/// True when the path has a supported model/migration file extension
27/// (`.json`, `.yaml`, `.yml`). Single source of truth for the loader's
28/// supported-extension set.
29pub(crate) fn has_supported_extension(path: &std::path::Path) -> bool {
30    matches!(
31        path.extension().and_then(|s| s.to_str()),
32        Some("json" | "yaml" | "yml")
33    )
34}
35pub use migrations::{load_migrations, load_migrations_at_compile_time, load_migrations_from_dir};
36pub use models::{load_models, load_models_at_compile_time, load_models_from_dir};