Skip to main content

StrPathExt

Trait StrPathExt 

Source
pub trait StrPathExt {
    // Required methods
    fn expand_tilde(&self) -> PathBuf;
    fn is_safe_path(&self) -> bool;
    fn validate_safety(&self) -> Result<()>;
    fn file_name_str(&self) -> String;
}
Expand description

Extension trait that adds path-related methods to str.

Provides ergonomic access to tilde expansion and path safety checks:

use vtcode_commons::paths::StrPathExt;

let expanded = "~/projects/vtcode".expand_tilde();
assert!(StrPathExt::is_safe_path("src/main.rs"));

Required Methods§

Source

fn expand_tilde(&self) -> PathBuf

Expand a leading ~ or ~/ to the user’s home directory.

Source

fn is_safe_path(&self) -> bool

Check if this path string is a safe relative path (no traversal, no absolute).

Source

fn validate_safety(&self) -> Result<()>

Validate that this path is safe to use (no traversal, no dangerous characters).

Source

fn file_name_str(&self) -> String

Extract the filename from this path string.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl StrPathExt for str

Implementors§