pub struct FilesystemGateway { /* private fields */ }Expand description
A gateway for interacting with the filesystem within a sandboxed base path.
This struct provides safe filesystem operations that are restricted to a specific base directory, preventing path traversal attacks.
Implementations§
Source§impl FilesystemGateway
impl FilesystemGateway
Sourcepub fn new<P: AsRef<Path>>(base_path: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(base_path: P) -> Result<Self>
Creates a new FilesystemGateway with the specified base path.
Sourcepub fn resolve_path<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>
pub fn resolve_path<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>
Resolves a path relative to the base path and ensures it stays within the sandbox.
Sourcepub fn ls<P: AsRef<Path>>(&self, path: P) -> Result<Vec<String>>
pub fn ls<P: AsRef<Path>>(&self, path: P) -> Result<Vec<String>>
Lists files in a directory (non-recursive).
Sourcepub fn list_all_files<P: AsRef<Path>>(&self, path: P) -> Result<Vec<String>>
pub fn list_all_files<P: AsRef<Path>>(&self, path: P) -> Result<Vec<String>>
Lists all files recursively in a directory.
Sourcepub fn find_files_by_glob<P: AsRef<Path>>(
&self,
path: P,
pattern: &str,
) -> Result<Vec<String>>
pub fn find_files_by_glob<P: AsRef<Path>>( &self, path: P, pattern: &str, ) -> Result<Vec<String>>
Finds files matching a glob pattern.
Sourcepub fn find_files_containing<P: AsRef<Path>>(
&self,
path: P,
pattern: &str,
) -> Result<Vec<String>>
pub fn find_files_containing<P: AsRef<Path>>( &self, path: P, pattern: &str, ) -> Result<Vec<String>>
Finds files containing text matching a regex pattern.
Sourcepub fn find_lines_matching<P: AsRef<Path>>(
&self,
path: P,
file_name: &str,
pattern: &str,
) -> Result<Vec<Value>>
pub fn find_lines_matching<P: AsRef<Path>>( &self, path: P, file_name: &str, pattern: &str, ) -> Result<Vec<Value>>
Finds all lines in a file matching a regex pattern.
Trait Implementations§
Source§impl Clone for FilesystemGateway
impl Clone for FilesystemGateway
Source§fn clone(&self) -> FilesystemGateway
fn clone(&self) -> FilesystemGateway
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FilesystemGateway
impl RefUnwindSafe for FilesystemGateway
impl Send for FilesystemGateway
impl Sync for FilesystemGateway
impl Unpin for FilesystemGateway
impl UnwindSafe for FilesystemGateway
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