pub struct FileGenerator { /* private fields */ }Expand description
Handles creation of files and directories on the filesystem
FileGenerator provides safe file operations with configurable overwrite behavior and proper error handling.
Implementations§
Source§impl FileGenerator
impl FileGenerator
Sourcepub fn with_force_overwrite(self, force: bool) -> Self
pub fn with_force_overwrite(self, force: bool) -> Self
Configure whether existing files should be overwritten
When force_overwrite is true, existing files will be replaced. When false, attempting to create existing files will return an error.
Sourcepub fn create_directory<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn create_directory<P: AsRef<Path>>(&self, path: P) -> Result<()>
Create a directory and all necessary parent directories
This method:
- Creates the directory and any missing parent directories
- Handles the case where the path already exists as a directory
- Returns an error if the path exists but is not a directory
Sourcepub fn create_file<P: AsRef<Path>>(&self, path: P, content: &str) -> Result<()>
pub fn create_file<P: AsRef<Path>>(&self, path: P, content: &str) -> Result<()>
Create a file with the specified content
This method:
- Checks for existing files and respects the force_overwrite setting
- Creates parent directories if they don’t exist
- Writes the content to the file (overwrites if file exists and force is true)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileGenerator
impl RefUnwindSafe for FileGenerator
impl Send for FileGenerator
impl Sync for FileGenerator
impl Unpin for FileGenerator
impl UnwindSafe for FileGenerator
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