FileOperations

Struct FileOperations 

Source
pub struct FileOperations;
Expand description

File operations wrapper ensuring PathResolver validation

Implementations§

Source§

impl FileOperations

Source

pub fn create_file(path: &str, content: &str) -> ExecutionResult<()>

Create a file with the specified content

§Arguments
  • path - File path (will be validated with PathResolver)
  • content - Content to write to the file
§Errors

Returns error if path is invalid or file creation fails

§Panics

Never panics; all errors are returned as ExecutionError

Source

pub fn modify_file(path: &str, diff: &str) -> ExecutionResult<()>

Modify a file by applying a diff

§Arguments
  • path - File path (will be validated with PathResolver)
  • diff - Diff to apply to the file
§Errors

Returns error if path is invalid, file doesn’t exist, or diff application fails

Source

pub fn delete_file(path: &str) -> ExecutionResult<()>

Delete a file

§Arguments
  • path - File path (will be validated with PathResolver)
§Errors

Returns error if path is invalid or file deletion fails

Source

pub fn backup_file(path: &str) -> ExecutionResult<PathBuf>

Backup a file before modification

Creates a backup copy of the file with a .backup extension.

§Arguments
  • path - File path (will be validated with PathResolver)
§Returns

Path to the backup file

§Errors

Returns error if path is invalid or backup creation fails

Source

pub fn restore_from_backup( file_path: &str, backup_path: &str, ) -> ExecutionResult<()>

Restore a file from backup

§Arguments
  • file_path - Original file path (will be validated with PathResolver)
  • backup_path - Backup file path (will be validated with PathResolver)
§Errors

Returns error if paths are invalid or restoration fails

Source

pub fn file_exists(path: &str) -> ExecutionResult<bool>

Check if a file exists

§Arguments
  • path - File path (will be validated with PathResolver)
§Returns

true if file exists, false otherwise

§Errors

Returns error if path is invalid

Source

pub fn read_file(path: &str) -> ExecutionResult<String>

Read file content

§Arguments
  • path - File path (will be validated with PathResolver)
§Returns

File content as string

§Errors

Returns error if path is invalid or file read fails

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more