pub struct CrossPath { /* private fields */ }Expand description
Main cross-platform path structure
Implementations§
Source§impl CrossPath
impl CrossPath
Sourcepub fn new<P: AsRef<str>>(path: P) -> PathResult<Self>
pub fn new<P: AsRef<str>>(path: P) -> PathResult<Self>
Sourcepub fn with_config<P: AsRef<str>>(
path: P,
config: PathConfig,
) -> PathResult<Self>
pub fn with_config<P: AsRef<str>>( path: P, config: PathConfig, ) -> PathResult<Self>
Sourcepub fn to_style(&self, style: PathStyle) -> PathResult<String>
pub fn to_style(&self, style: PathStyle) -> PathResult<String>
Sourcepub fn to_platform(&self) -> PathResult<String>
pub fn to_platform(&self) -> PathResult<String>
Convert to platform-appropriate path
Automatically detects the current operating system and converts the path to the native format.
§Errors
Returns PathError if conversion fails
Sourcepub fn to_windows(&self) -> PathResult<String>
pub fn to_windows(&self) -> PathResult<String>
Convert to Windows path
Forces conversion to Windows style (e.g., C:\path\to\file)
§Errors
Returns PathError if conversion fails
Sourcepub fn to_unix(&self) -> PathResult<String>
pub fn to_unix(&self) -> PathResult<String>
Convert to Unix path
Forces conversion to Unix style (e.g., /mnt/c/path/to/file)
§Errors
Returns PathError if conversion fails
Sourcepub fn as_original(&self) -> &Path
pub fn as_original(&self) -> &Path
Get original path
Sourcepub fn set_config(&mut self, config: PathConfig)
pub fn set_config(&mut self, config: PathConfig)
Update configuration
Sourcepub fn config(&self) -> &PathConfig
pub fn config(&self) -> &PathConfig
Get configuration reference
Sourcepub fn is_safe(&self) -> PathResult<bool>
pub fn is_safe(&self) -> PathResult<bool>
Check if path is safe
Performs security checks including:
- Path traversal detection
- Dangerous pattern detection
- System directory access check
§Errors
Returns PathError if security check fails
Sourcepub fn normalize(&mut self) -> PathResult<()>
pub fn normalize(&mut self) -> PathResult<()>
Normalize path
Removes redundant components like . and ..
§Errors
Returns PathError if normalization fails
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CrossPath
impl<'de> Deserialize<'de> for CrossPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CrossPath
impl StructuralPartialEq for CrossPath
Auto Trait Implementations§
impl Freeze for CrossPath
impl RefUnwindSafe for CrossPath
impl Send for CrossPath
impl Sync for CrossPath
impl Unpin for CrossPath
impl UnwindSafe for CrossPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more