refactor: extract hm-util crate + modernize CancellationToken#5
Merged
Conversation
…cellationToken Eliminates 55-line Arc<AtomicBool> wrapper. The 50ms polling loop in wait_cancel is replaced by the zero-cost .cancelled() future.
Add hm-util to workspace crate listing. Update orchestrator docs to reflect CancellationToken is now tokio_util::sync, not a custom module.
Main removed anyhow from workspace.dependencies; hm-util still referenced it via workspace = true.
- os::fs returns std::io::Result instead of anyhow::Result - os::dirs returns Option<PathBuf> instead of anyhow::Result - os::dirs adds sys_config_dir() for /etc (Unix) / C:\ProgramData (Win) - New top-level dirs module for harmont config dir discovery (searches ~/.hm then /etc/hm) - Update hm callers for new return types
- Merge os::dirs primitives (home_dir, config_dir, sys_config_dir) into hm_util::dirs alongside harmont-specific discovery - Delete os/dirs.rs — hm_util::dirs is the sole public API - Update all hm callers from hm_util::os::dirs to hm_util::dirs - Add prohibition comment in hm/src/lib.rs: dirs crate must not be added as a direct dependency of hm
Move raw `dirs::` calls into private `os::dirs` module within hm-util. Public `hm_util::dirs` now exposes only Harmont-specific accessors: harmont_config_dir, harmont_data_dir, harmont_plugins_dir, harmont_plugin_state_dir. No raw system directory calls leak into hm.
unreachable_pub (rustc) and redundant_pub_crate (clippy) contradict each other for pub(crate) items inside non-pub modules. Keep the rustc lint, suppress the clippy one globally.
Remove duplicate sync code paths — blocking:: now shells out to the async API through tokio::task::block_in_place. Platform-specific rename logic moves from standalone _sync functions to private _impl helpers positioned after the public async fn.
atomic_rename_over now delegates to tokio::fs::rename on Unix. write_atomic_restricted splits its spawn_blocking so the rename step goes through the async atomic_rename_over. The sync Unix atomic_rename_over_impl is removed (only Windows variant remains).
create_dir_with_mode and write_file_with_mode now use tokio::fs instead of std::fs. This eliminates the last spawn_blocking from write_atomic_restricted — all I/O goes through tokio's async API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.