pub struct StoragePath { /* private fields */ }
Expand description
A file or folder path.
§Base & Extension
Storage paths are divided into a base and an extension. The base is effectively immutable and the extension is a sequence of segments divided by file-separators.
Unix Example: Path: /the/path Base: / Extension: the/path
Windows Example:
Path: C:\The\Path
Base: C:
Extension: The\Path
URL Example: Path: https://example.com/the/path Base: https://example.com/ Extension: the/path
§Files & Folders
A storage path can be a file path or a folder path. These are mutually exclusive and exhaustive. A storage path is a folder path if it is equal to its base or ends with a file-separator, otherwise it is a file path.
Implementations§
Source§impl StoragePath
Construction
impl StoragePath
Construction
Source§impl StoragePath
Properties
impl StoragePath
Properties
Source§impl StoragePath
Parse
impl StoragePath
Parse
Source§impl StoragePath
Roots
impl StoragePath
Roots
Source§impl StoragePath
To File or Folder
impl StoragePath
To File or Folder
Source§impl StoragePath
Clone
impl StoragePath
Clone
Sourcepub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self
pub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self
Clones the path with the extra capacity.
Source§impl StoragePath
Append
impl StoragePath
Append
Sourcepub fn with_appended<S>(self, string: S) -> Self
pub fn with_appended<S>(self, string: S) -> Self
Appends the string
.
Sourcepub fn clone_append<S>(&self, string: S) -> Self
pub fn clone_append<S>(&self, string: S) -> Self
Clones the path and appends the string
.
The result is the same as path.clone().with_appended(s)
but with a single allocation.
Source§impl StoragePath
Append Char
impl StoragePath
Append Char
Sourcepub fn append_char(&mut self, c: char)
pub fn append_char(&mut self, c: char)
Appends the char.
Sourcepub fn with_appended_char(self, c: char) -> Self
pub fn with_appended_char(self, c: char) -> Self
Appends the char.
Source§impl StoragePath
Make File
impl StoragePath
Make File
Sourcepub fn make_file(self, file_name: &str) -> Result<FilePath, Error>
pub fn make_file(self, file_name: &str) -> Result<FilePath, Error>
Makes the path a file path.
If the path is a file the file will be returned.
If the path is a folder the file_name
will be appended then:
1. If the path is a file the file will be returned.
2. If the file_name
is empty or ends with the file-separator it will be None
.
Source§impl StoragePath
Make Folder
impl StoragePath
Make Folder
Sourcepub fn clone_make_folder(&self) -> FolderPath
pub fn clone_make_folder(&self) -> FolderPath
Clones the path and makes the path a folder.
Returns the path as is if it is already a folder, otherwise appends a file-separator.
Sourcepub fn make_folder(self) -> FolderPath
pub fn make_folder(self) -> FolderPath
Makes the storage path a folder.
Returns the path as is if it is already a folder, otherwise appends a file-separator.
Source§impl StoragePath
Truncate
impl StoragePath
Truncate
Source§impl StoragePath
Base & Extension
impl StoragePath
Base & Extension
Source§impl StoragePath
File or Folder
impl StoragePath
File or Folder
Source§impl StoragePath
Length
impl StoragePath
Length
Source§impl StoragePath
Is System
impl StoragePath
Is System
Sourcepub fn is_local_path(&self) -> bool
pub fn is_local_path(&self) -> bool
Checks if the path is a local path.
Sourcepub fn is_local_path_str<S>(path: S) -> bool
pub fn is_local_path_str<S>(path: S) -> bool
Checks if the path
is a local path.
Source§impl StoragePath
Is System
impl StoragePath
Is System
Sourcepub fn is_unix_path(&self) -> bool
pub fn is_unix_path(&self) -> bool
Checks if the path is a unix path.
Sourcepub fn is_unix_path_str<S>(path: S) -> bool
pub fn is_unix_path_str<S>(path: S) -> bool
Checks if the path
is a unix path.
Source§impl StoragePath
Is System
impl StoragePath
Is System
Sourcepub fn is_windows_path(&self) -> bool
pub fn is_windows_path(&self) -> bool
Checks if the path is a windows path.
Sourcepub fn is_windows_path_str<S>(path: S) -> bool
pub fn is_windows_path_str<S>(path: S) -> bool
Checks if the path
is a windows path.
Trait Implementations§
Source§impl AsRef<OsStr> for StoragePath
impl AsRef<OsStr> for StoragePath
Source§impl AsRef<Path> for StoragePath
impl AsRef<Path> for StoragePath
Source§impl AsRef<StoragePath> for StoragePath
impl AsRef<StoragePath> for StoragePath
Source§fn as_ref(&self) -> &StoragePath
fn as_ref(&self) -> &StoragePath
Source§impl AsRef<str> for StoragePath
impl AsRef<str> for StoragePath
Source§impl Clone for StoragePath
impl Clone for StoragePath
Source§fn clone(&self) -> StoragePath
fn clone(&self) -> StoragePath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more