Crate workspace_tools

Source
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

  1. Configure cargo in workspace root .cargo/config.toml:
[env]
WORKSPACE_PATH = { value = ".", relative = true }
  1. 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
  • secret_management: provides secure configuration file handling utilities

Modules§

testing
testing utilities for workspace functionality

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

Functions§

workspace
convenience function to get workspace instance

Type Aliases§

Result
result type for workspace operations