pub fn join<R, P>(root: R, path: P) -> Result<PathBuf, JailError>Expand description
Validate a path in one shot.
This is a convenience wrapper around Jail::new and Jail::join.
For validating multiple paths against the same root, create a Jail
and reuse it for better performance.
§Arguments
root: The jail root directory (must exist and be a directory)path: A relative path to validate and join to the root
§Returns
The canonicalized safe path, or an error if:
- The root doesn’t exist or isn’t a directory
- The path would escape the jail
- The path is absolute
§Example
// Validate user input before saving a file
let safe = path_jail::join("/var/uploads", user_input)?;
std::fs::write(&safe, data)?;