Expand description
Universal workspace-relative path resolution for Rust projects
This crate provides consistent, reliable path management regardless of execution context or working directory. It solves common path resolution issues in software projects by leveraging cargo’s environment variable injection system.
§problem solved
- execution context dependency: paths break when code runs from different directories
- environment inconsistency: different developers have different working directory habits
- testing fragility: tests fail when run from different locations
- ci/cd brittleness: automated systems may execute from unexpected directories
§quick start
- Configure cargo in workspace root
.cargo/config.toml
:
[env]
WORKSPACE_PATH = { value = ".", relative = true }
- Use in your code:
use workspace_tools::{ workspace, WorkspaceError };
// get workspace instance
let ws = workspace()?;
// resolve workspace-relative paths
let config_path = ws.config_dir().join( "app.toml" );
let data_path = ws.data_dir().join( "cache.db" );
§features
glob
: enables pattern-based resource discoverysecret_management
: provides secure configuration file handling utilities
Modules§
- testing
- testing utilities for workspace functionality
Structs§
- Cargo
Metadata - cargo metadata information for workspace
- Cargo
Package - information about a cargo package within a workspace
- Workspace
- workspace path resolver providing centralized access to workspace-relative paths
- Workspace
Deserializer - workspace-aware serde deserializer
- Workspace
Path - custom serde field for workspace-relative paths
Enums§
- Workspace
Error - workspace path resolution errors
Traits§
- Config
Merge - trait for configuration types that can be merged
Functions§
- workspace
- convenience function to get workspace instance
Type Aliases§
- Result
- result type for workspace operations