pub struct FilePath { /* private fields */ }
Expand description
A file path.
Implementations§
Source§impl FilePath
Read String
impl FilePath
Read String
Sourcepub fn read_as_string(&self) -> Result<String, Error>
pub fn read_as_string(&self) -> Result<String, Error>
Reads the file as a String
.
Returns Ok(file_content)
.
Returns Err(FileNotFound)
if the file did not exist.
Sourcepub fn read_as_string_if_exists(&self) -> Result<Option<String>, Error>
pub fn read_as_string_if_exists(&self) -> Result<Option<String>, Error>
Reads the file as a String
if it exists.
Returns Ok(Some(file_content))
.
Returns Ok(None)
if the file did not exist.
Source§impl FilePath
Read Vec
impl FilePath
Read Vec
Sourcepub fn read_as_vec(&self) -> Result<Vec<u8>, Error>
pub fn read_as_vec(&self) -> Result<Vec<u8>, Error>
Reads the file as a Vec
.
Returns Ok(file_content)
.
Returns Err(FileNotFound)
if the file did not exist.
Sourcepub fn read_as_vec_if_exists(&self) -> Result<Option<Vec<u8>>, Error>
pub fn read_as_vec_if_exists(&self) -> Result<Option<Vec<u8>>, Error>
Reads the file as a Vec
if it exists.
Returns Ok(Some(file_content))
.
Returns Ok(None)
if the file did not exist.
Source§impl FilePath
Write
impl FilePath
Write
Source§impl FilePath
Write Empty
impl FilePath
Write Empty
Sourcepub fn write_empty(&self) -> Result<(), Error>
pub fn write_empty(&self) -> Result<(), Error>
Writes an empty file.
Returns Ok(())
.
Returns Err(FileAlreadyExists)
if the file already exists.
Sourcepub fn write_empty_if_not_exists(&self) -> Result<bool, Error>
pub fn write_empty_if_not_exists(&self) -> Result<bool, Error>
Writes an empty file if the file does not exist.
Returns Ok(true)
if the file was written.
Returns Ok(false)
if the file already exists.
Source§impl FilePath
Write Data
impl FilePath
Write Data
Sourcepub fn write_slice<D>(&self, slice: D) -> Result<(), Error>
pub fn write_slice<D>(&self, slice: D) -> Result<(), Error>
Writes the slice
to the file.
Returns Ok(())
.
Returns Err(FileAlreadyExists)
if the file already exists.
Source§impl FilePath
Write String
impl FilePath
Write String
Source§impl FilePath
Delete
impl FilePath
Delete
Sourcepub fn delete(&self) -> Result<(), Error>
pub fn delete(&self) -> Result<(), Error>
Deletes the file.
Returns Ok(())
if the file was deleted or if the file did not exist.
Sourcepub fn delete_if_exists(&self) -> Result<bool, Error>
pub fn delete_if_exists(&self) -> Result<bool, Error>
Deletes the file if it exists.
Returns Ok(true)
if the file existed and was deleted.
Returns Ok(false)
if the file did not exist.
Source§impl FilePath
Storage Path
impl FilePath
Storage Path
Sourcepub fn path(&self) -> &StoragePath
pub fn path(&self) -> &StoragePath
Gets the storage path.
Sourcepub fn to_path(self) -> StoragePath
pub fn to_path(self) -> StoragePath
Converts the file path to a storage path.
Source§impl FilePath
Clone
impl FilePath
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 FilePath
Append
impl FilePath
Append
Sourcepub fn with_appended<S>(self, string: S) -> StoragePath
pub fn with_appended<S>(self, string: S) -> StoragePath
Appends the string
.
Sourcepub fn clone_append<S>(&self, string: S) -> StoragePath
pub fn clone_append<S>(&self, string: S) -> StoragePath
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 FilePath
Append Char
impl FilePath
Append Char
Sourcepub fn with_appended_char(self, c: char) -> StoragePath
pub fn with_appended_char(self, c: char) -> StoragePath
Appends the char.
Source§impl FilePath
Make Folder
impl FilePath
Make Folder
Sourcepub fn make_folder(self) -> FolderPath
pub fn make_folder(self) -> FolderPath
Makes the file a folder by appending a file separator.
Source§impl FilePath
Is System
impl FilePath
Is System
Sourcepub fn is_local_path(&self) -> bool
pub fn is_local_path(&self) -> bool
Checks if the path is a local path.