pub struct PluginFileSystem { /* private fields */ }Expand description
An AsyncFileSystem backed by an Extism storage plugin.
All trait methods dispatch to plugin commands (ReadFile, WriteFile, etc.) and parse the JSON response.
Implementations§
Source§impl PluginFileSystem
impl PluginFileSystem
pub fn new(plugin: Arc<Mutex<ExtismPluginAdapter>>) -> Self
Trait Implementations§
Source§impl AsyncFileSystem for PluginFileSystem
impl AsyncFileSystem for PluginFileSystem
Source§fn read_to_string<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<String>>
fn read_to_string<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<String>>
Reads the file content as a string.
Source§fn write_file<'a>(
&'a self,
path: &'a Path,
content: &'a str,
) -> BoxFuture<'a, Result<()>>
fn write_file<'a>( &'a self, path: &'a Path, content: &'a str, ) -> BoxFuture<'a, Result<()>>
Overwrites an existing file with new content.
Source§fn create_new<'a>(
&'a self,
path: &'a Path,
content: &'a str,
) -> BoxFuture<'a, Result<()>>
fn create_new<'a>( &'a self, path: &'a Path, content: &'a str, ) -> BoxFuture<'a, Result<()>>
Creates a file ONLY if it doesn’t exist.
Should return an error if file exists.
Source§fn list_md_files<'a>(
&'a self,
dir: &'a Path,
) -> BoxFuture<'a, Result<Vec<PathBuf>>>
fn list_md_files<'a>( &'a self, dir: &'a Path, ) -> BoxFuture<'a, Result<Vec<PathBuf>>>
Finds markdown files in a folder.
Source§fn exists<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, bool>
fn exists<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, bool>
Checks if a file or directory exists.
Source§fn create_dir_all<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<()>>
fn create_dir_all<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<()>>
Creates a directory and all parent directories.
Source§fn is_dir<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, bool>
fn is_dir<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, bool>
Checks if a path is a directory.
Source§fn read_binary<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<Vec<u8>>>
fn read_binary<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<Vec<u8>>>
Read binary file content.
Source§fn hash_file<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<String>>
fn hash_file<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<String>>
Compute the SHA-256 hash of a file and return it as lowercase hex.
Source§fn write_binary<'a>(
&'a self,
path: &'a Path,
content: &'a [u8],
) -> BoxFuture<'a, Result<()>>
fn write_binary<'a>( &'a self, path: &'a Path, content: &'a [u8], ) -> BoxFuture<'a, Result<()>>
Write binary content to a file.
Source§fn list_files<'a>(
&'a self,
dir: &'a Path,
) -> BoxFuture<'a, Result<Vec<PathBuf>>>
fn list_files<'a>( &'a self, dir: &'a Path, ) -> BoxFuture<'a, Result<Vec<PathBuf>>>
List all files in a directory (not recursive).
Source§fn get_modified_time<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Option<i64>>
fn get_modified_time<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Option<i64>>
Get file modification time as milliseconds since Unix epoch. Read more
Source§fn is_symlink<'a>(
&'a self,
_path: &'a Path,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>
fn is_symlink<'a>( &'a self, _path: &'a Path, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>
Checks if a path is a symlink.
Returns false for non-existent paths or on platforms that don’t support symlinks.
Source§fn clear_dir<'a>(
&'a self,
dir: &'a Path,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn clear_dir<'a>( &'a self, dir: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Delete all files and subdirectories within a directory.
The directory itself is preserved (remains as an empty directory).
Source§fn list_md_files_recursive<'a>(
&'a self,
dir: &'a Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<PathBuf>, Error>> + Send + 'a>>
fn list_md_files_recursive<'a>( &'a self, dir: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<PathBuf>, Error>> + Send + 'a>>
Recursively list all markdown files in a directory and its subdirectories.
Source§fn list_all_files_recursive<'a>(
&'a self,
dir: &'a Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<PathBuf>, Error>> + Send + 'a>>
fn list_all_files_recursive<'a>( &'a self, dir: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<PathBuf>, Error>> + Send + 'a>>
Recursively list ALL files and directories in a directory.
Source§fn get_file_size<'a>(
&'a self,
_path: &'a Path,
) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'a>>
fn get_file_size<'a>( &'a self, _path: &'a Path, ) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'a>>
Get file size in bytes. Read more
Source§fn mark_sync_write_start(&self, _path: &Path)
fn mark_sync_write_start(&self, _path: &Path)
Mark a path as being written from sync (skip CRDT updates if applicable). Read more
Source§fn mark_sync_write_end(&self, _path: &Path)
fn mark_sync_write_end(&self, _path: &Path)
Clear the sync write marker for a path. Read more
Auto Trait Implementations§
impl Freeze for PluginFileSystem
impl RefUnwindSafe for PluginFileSystem
impl Send for PluginFileSystem
impl Sync for PluginFileSystem
impl Unpin for PluginFileSystem
impl UnsafeUnpin for PluginFileSystem
impl UnwindSafe for PluginFileSystem
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more