From 353fdc5b539aae0479c7404d0ed6404f82bf633a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 27 Jun 2026 18:52:49 +0800 Subject: feat(mingling): add directory environment resources and setup Add four new resource types for common directory paths and a convenience setup struct that registers all of them at once. --- mingling/src/setups/dirs.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 mingling/src/setups/dirs.rs (limited to 'mingling/src/setups/dirs.rs') diff --git a/mingling/src/setups/dirs.rs b/mingling/src/setups/dirs.rs new file mode 100644 index 0000000..a7f81fa --- /dev/null +++ b/mingling/src/setups/dirs.rs @@ -0,0 +1,42 @@ +use std::marker::PhantomData; + +use mingling_core::{ + ProgramCollect, + setup::ProgramSetup, +}; + +use crate::res::{ResCurrentDir, ResCurrentExe, ResHomeDir, ResTempDir}; + +/// Provides the ability to set up commonly used directory resources for the program. +/// +/// This setup item registers the following directory resources in the program: +/// - `ResCurrentDir`: Current working directory +/// - `ResCurrentExe`: Directory containing the executable +/// - `ResHomeDir`: User's home directory +/// - `ResTempDir`: Temporary directory +pub struct DirectoryEnvironmentSetup { + _collect: PhantomData, +} + +impl Default for DirectoryEnvironmentSetup +where + C: ProgramCollect + 'static, +{ + fn default() -> Self { + Self { + _collect: PhantomData, + } + } +} + +impl ProgramSetup for DirectoryEnvironmentSetup +where + C: ProgramCollect + 'static, +{ + fn setup(self, program: &mut crate::Program) { + program.with_resource(ResCurrentDir::default()); + program.with_resource(ResCurrentExe::default()); + program.with_resource(ResHomeDir::default()); + program.with_resource(ResTempDir::default()); + } +} -- cgit