pub struct FileTool;Expand description
File utility wrapper
Implementations§
Source§impl FileTool
impl FileTool
Sourcepub fn read_string<P: AsRef<Path>>(&self, path: P) -> Result<String>
pub fn read_string<P: AsRef<Path>>(&self, path: P) -> Result<String>
Read the entire contents of a file into a string
Sourcepub fn read_bytes<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>
pub fn read_bytes<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>
Read the entire contents of a file into a bytes vector
Sourcepub fn write_string<P: AsRef<Path>, C: AsRef<[u8]>>(
&self,
path: P,
content: C,
) -> Result<()>
pub fn write_string<P: AsRef<Path>, C: AsRef<[u8]>>( &self, path: P, content: C, ) -> Result<()>
Write a string to a file (creates or overwrites)
Sourcepub fn mkdir<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn mkdir<P: AsRef<Path>>(&self, path: P) -> Result<()>
Create a single directory (fails if parent doesn’t exist)
Sourcepub fn mkdir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn mkdir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
Recursively create a directory and all of its parent components if they are missing
Sourcepub fn delete_recursive<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn delete_recursive<P: AsRef<Path>>(&self, path: P) -> Result<()>
Recursively delete a directory and all of its contents
Sourcepub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: P,
to: Q,
) -> Result<u64>
pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>( &self, from: P, to: Q, ) -> Result<u64>
Copy a file
Sourcepub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: P,
to: Q,
) -> Result<()>
pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>( &self, from: P, to: Q, ) -> Result<()>
Rename or move a file/directory
Auto Trait Implementations§
impl Freeze for FileTool
impl RefUnwindSafe for FileTool
impl Send for FileTool
impl Sync for FileTool
impl Unpin for FileTool
impl UnsafeUnpin for FileTool
impl UnwindSafe for FileTool
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