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 discovery
- secrets: provides secure configuration file handling utilities
- secure: enables memory-safe secret handling with the secrecy crate
- serde: provides configuration loading with serde support
- validation: enables configuration validation with JSON Schema
§security best practices
when using the secure feature for secret management :
- secrets are wrapped in SecretStringtypes that prevent accidental exposure
- debug output automatically redacts secret values
- secrets require explicit expose_secret()calls for access
- use the SecretInjectabletrait for automatic configuration injection
- validate secret strength with validate_secret()method
- secrets are zeroized from memory when dropped
Structs§
- CargoMetadata 
- cargo metadata information for workspace
- CargoPackage 
- information about a cargo package within a workspace
- Workspace
- workspace path resolver providing centralized access to workspace-relative paths
- WorkspaceDeserializer 
- workspace-aware serde deserializer
- WorkspacePath 
- custom serde field for workspace-relative paths
Enums§
- WorkspaceError 
- workspace path resolution errors
Traits§
- ConfigMerge 
- trait for configuration types that can be merged
- SecretInjectable 
- trait for types that support automatic secret injection
Functions§
- workspace
- convenience function to get workspace instance
Type Aliases§
- Result
- result type for workspace operations