pub struct VirtualPath<Marker = ()> { /* private fields */ }Expand description
SUMMARY:
Hold a user‑facing path clamped to a virtual root ("/") over a PathBoundary.
DETAILS:
virtualpath_display() shows rooted, forward‑slashed paths (e.g., "/a/b.txt").
Use virtual manipulation methods to compose paths while preserving clamping, then convert to
StrictPath with unvirtual() for system‑facing I/O.
Implementations§
Source§impl<Marker> VirtualPath<Marker>
impl<Marker> VirtualPath<Marker>
Sourcepub fn with_root<P: AsRef<Path>>(root: P) -> Result<Self>
pub fn with_root<P: AsRef<Path>>(root: P) -> Result<Self>
SUMMARY:
Create the virtual root ("/") for the given filesystem root.
Sourcepub fn with_root_create<P: AsRef<Path>>(root: P) -> Result<Self>
pub fn with_root_create<P: AsRef<Path>>(root: P) -> Result<Self>
SUMMARY: Create the virtual root, creating the filesystem root if missing.
Sourcepub fn unvirtual(self) -> StrictPath<Marker>
pub fn unvirtual(self) -> StrictPath<Marker>
SUMMARY:
Convert this VirtualPath back into a system‑facing StrictPath.
Sourcepub fn try_into_root(self) -> VirtualRoot<Marker>
pub fn try_into_root(self) -> VirtualRoot<Marker>
SUMMARY:
Consume and return the VirtualRoot for its boundary (no directory creation).
Sourcepub fn try_into_root_create(self) -> VirtualRoot<Marker>
pub fn try_into_root_create(self) -> VirtualRoot<Marker>
SUMMARY:
Consume and return a VirtualRoot, creating the underlying directory if missing.
Sourcepub fn as_unvirtual(&self) -> &StrictPath<Marker>
pub fn as_unvirtual(&self) -> &StrictPath<Marker>
SUMMARY:
Borrow the underlying system‑facing StrictPath (no allocation).
Sourcepub fn interop_path(&self) -> &OsStr
pub fn interop_path(&self) -> &OsStr
SUMMARY:
Return the underlying system path as &OsStr for AsRef<Path> interop.
Sourcepub fn virtual_join<P: AsRef<Path>>(&self, path: P) -> Result<Self>
pub fn virtual_join<P: AsRef<Path>>(&self, path: P) -> Result<Self>
SUMMARY: Join a virtual path segment (virtual semantics) and re‑validate within the same restriction.
Sourcepub fn virtualpath_parent(&self) -> Result<Option<Self>>
pub fn virtualpath_parent(&self) -> Result<Option<Self>>
SUMMARY:
Return the parent virtual path, or None at the virtual root.
Sourcepub fn virtualpath_with_file_name<S: AsRef<OsStr>>(
&self,
file_name: S,
) -> Result<Self>
pub fn virtualpath_with_file_name<S: AsRef<OsStr>>( &self, file_name: S, ) -> Result<Self>
SUMMARY: Return a new virtual path with file name changed, preserving clamping.
Sourcepub fn virtualpath_with_extension<S: AsRef<OsStr>>(
&self,
extension: S,
) -> Result<Self>
pub fn virtualpath_with_extension<S: AsRef<OsStr>>( &self, extension: S, ) -> Result<Self>
SUMMARY: Return a new virtual path with the extension changed, preserving clamping.
Sourcepub fn virtualpath_file_name(&self) -> Option<&OsStr>
pub fn virtualpath_file_name(&self) -> Option<&OsStr>
SUMMARY: Return the file name component of the virtual path, if any.
Sourcepub fn virtualpath_file_stem(&self) -> Option<&OsStr>
pub fn virtualpath_file_stem(&self) -> Option<&OsStr>
SUMMARY: Return the file stem of the virtual path, if any.
Sourcepub fn virtualpath_extension(&self) -> Option<&OsStr>
pub fn virtualpath_extension(&self) -> Option<&OsStr>
SUMMARY: Return the extension of the virtual path, if any.
Sourcepub fn virtualpath_starts_with<P: AsRef<Path>>(&self, p: P) -> bool
pub fn virtualpath_starts_with<P: AsRef<Path>>(&self, p: P) -> bool
SUMMARY:
Return true if the virtual path starts with the given prefix (virtual semantics).
Sourcepub fn virtualpath_ends_with<P: AsRef<Path>>(&self, p: P) -> bool
pub fn virtualpath_ends_with<P: AsRef<Path>>(&self, p: P) -> bool
SUMMARY:
Return true if the virtual path ends with the given suffix (virtual semantics).
Sourcepub fn virtualpath_display(&self) -> VirtualPathDisplay<'_, Marker>
pub fn virtualpath_display(&self) -> VirtualPathDisplay<'_, Marker>
SUMMARY: Return a Display wrapper that shows a rooted virtual path (e.g., `“/a/b.txt”).
Sourcepub fn is_dir(&self) -> bool
pub fn is_dir(&self) -> bool
SUMMARY:
Return true if the underlying system path is a directory.
Sourcepub fn metadata(&self) -> Result<Metadata>
pub fn metadata(&self) -> Result<Metadata>
SUMMARY: Return metadata for the underlying system path.
Sourcepub fn read_to_string(&self) -> Result<String>
pub fn read_to_string(&self) -> Result<String>
SUMMARY:
Read the file contents as String from the underlying system path.
Sourcepub fn read_bytes(&self) -> Result<Vec<u8>>
👎Deprecated since 0.1.0-alpha.5: Use read() instead
pub fn read_bytes(&self) -> Result<Vec<u8>>
Reads the file contents as raw bytes from the underlying system path.
Sourcepub fn write_bytes(&self, data: &[u8]) -> Result<()>
👎Deprecated since 0.1.0-alpha.5: Use write(…) instead
pub fn write_bytes(&self, data: &[u8]) -> Result<()>
Writes raw bytes to the underlying system path.
Sourcepub fn write_string(&self, data: &str) -> Result<()>
👎Deprecated since 0.1.0-alpha.5: Use write(…) instead
pub fn write_string(&self, data: &str) -> Result<()>
Writes a UTF-8 string to the underlying system path.
Sourcepub fn read(&self) -> Result<Vec<u8>>
pub fn read(&self) -> Result<Vec<u8>>
SUMMARY:
Read raw bytes from the underlying system path (replacement for read_bytes).
Sourcepub fn read_dir(&self) -> Result<ReadDir>
pub fn read_dir(&self) -> Result<ReadDir>
SUMMARY:
Read directory entries (discovery). Re‑join names with virtual_join(...) to preserve clamping.
Sourcepub fn write<C: AsRef<[u8]>>(&self, contents: C) -> Result<()>
pub fn write<C: AsRef<[u8]>>(&self, contents: C) -> Result<()>
SUMMARY:
Write bytes to the underlying system path. Accepts &str, String, &[u8], Vec<u8], etc.
Sourcepub fn create_dir_all(&self) -> Result<()>
pub fn create_dir_all(&self) -> Result<()>
SUMMARY: Create all directories in the underlying system path if missing.
Sourcepub fn create_dir(&self) -> Result<()>
pub fn create_dir(&self) -> Result<()>
SUMMARY: Create the directory at this virtual location (non‑recursive). Fails if parent missing.
Sourcepub fn create_parent_dir(&self) -> Result<()>
pub fn create_parent_dir(&self) -> Result<()>
SUMMARY:
Create only the immediate parent of this virtual path (non‑recursive). Ok(()) at virtual root.
Sourcepub fn create_parent_dir_all(&self) -> Result<()>
pub fn create_parent_dir_all(&self) -> Result<()>
SUMMARY:
Recursively create all missing directories up to the immediate parent. Ok(()) at virtual root.
Sourcepub fn remove_file(&self) -> Result<()>
pub fn remove_file(&self) -> Result<()>
SUMMARY: Remove the file at the underlying system path.
Sourcepub fn remove_dir(&self) -> Result<()>
pub fn remove_dir(&self) -> Result<()>
SUMMARY: Remove the directory at the underlying system path.
Sourcepub fn remove_dir_all(&self) -> Result<()>
pub fn remove_dir_all(&self) -> Result<()>
SUMMARY: Recursively remove the directory and its contents at the underlying system path.
Sourcepub fn virtual_symlink(&self, link_path: &Self) -> Result<()>
pub fn virtual_symlink(&self, link_path: &Self) -> Result<()>
SUMMARY:
Create a symlink at this virtual location pointing to target (same virtual root required).
Sourcepub fn virtual_hard_link(&self, link_path: &Self) -> Result<()>
pub fn virtual_hard_link(&self, link_path: &Self) -> Result<()>
SUMMARY:
Create a hard link at this virtual location pointing to target (same virtual root).
Trait Implementations§
Source§impl<Marker: Clone> Clone for VirtualPath<Marker>
impl<Marker: Clone> Clone for VirtualPath<Marker>
Source§fn clone(&self) -> VirtualPath<Marker>
fn clone(&self) -> VirtualPath<Marker>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more