pub struct LocalFilesStore { /* private fields */ }Expand description
Store for managing local files in database
Implementations§
Source§impl LocalFilesStore
impl LocalFilesStore
Sourcepub fn new(
pool: Arc<Pool<SqliteConnectionManager>>,
app_data_dir: PathBuf,
) -> Self
pub fn new( pool: Arc<Pool<SqliteConnectionManager>>, app_data_dir: PathBuf, ) -> Self
Create a new local files store
Sourcepub fn get_app_data_dir(&self) -> &Path
pub fn get_app_data_dir(&self) -> &Path
Get the app data directory path
Sourcepub fn create_folder(
&self,
parent_id: Option<i64>,
name: &str,
) -> Result<LocalFile>
pub fn create_folder( &self, parent_id: Option<i64>, name: &str, ) -> Result<LocalFile>
Create a folder
Sourcepub fn upload_file(
&self,
parent_id: Option<i64>,
name: &str,
content: &[u8],
mime_type: Option<&str>,
) -> Result<LocalFile>
pub fn upload_file( &self, parent_id: Option<i64>, name: &str, content: &[u8], mime_type: Option<&str>, ) -> Result<LocalFile>
Upload a file
Sourcepub fn list_files(&self, parent_id: Option<i64>) -> Result<Vec<LocalFile>>
pub fn list_files(&self, parent_id: Option<i64>) -> Result<Vec<LocalFile>>
List files in a directory (or root if parent_id is None)
Sourcepub fn get_file_by_path(&self, path: &str) -> Result<LocalFile>
pub fn get_file_by_path(&self, path: &str) -> Result<LocalFile>
Get file by path
Sourcepub fn get_file_by_name(&self, name: &str) -> Result<LocalFile>
pub fn get_file_by_name(&self, name: &str) -> Result<LocalFile>
Get file by name (searches all files, returns first match)
Sourcepub fn get_file_content_string(&self, id: i64) -> Result<String>
pub fn get_file_content_string(&self, id: i64) -> Result<String>
Get file content as string
Sourcepub fn delete_file(&self, id: i64) -> Result<()>
pub fn delete_file(&self, id: i64) -> Result<()>
Delete a file or folder (recursively)
Sourcepub fn search_files(&self, query: &str) -> Result<Vec<LocalFile>>
pub fn search_files(&self, query: &str) -> Result<Vec<LocalFile>>
Search files by name (partial match)
Sourcepub fn get_file_tree(&self) -> Result<Vec<LocalFileTree>>
pub fn get_file_tree(&self) -> Result<Vec<LocalFileTree>>
Get the complete file tree (nested structure)
Sourcepub fn get_all_files(&self) -> Result<Vec<LocalFile>>
pub fn get_all_files(&self) -> Result<Vec<LocalFile>>
Get all files (flat list)
Sourcepub fn sync_from_filesystem(&self) -> Result<usize>
pub fn sync_from_filesystem(&self) -> Result<usize>
Sync filesystem with database (import existing files)
Auto Trait Implementations§
impl Freeze for LocalFilesStore
impl !RefUnwindSafe for LocalFilesStore
impl Send for LocalFilesStore
impl Sync for LocalFilesStore
impl Unpin for LocalFilesStore
impl UnsafeUnpin for LocalFilesStore
impl !UnwindSafe for LocalFilesStore
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> 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