pub struct SqliteFs { /* private fields */ }
Expand description
Holds the path of the FS file and the DB Pool
Implementations§
Source§impl SqliteFs
impl SqliteFs
Sourcepub async fn init(mode: FsMode) -> Result<(), FsStatus>
pub async fn init(mode: FsMode) -> Result<(), FsStatus>
Init the SQLite Filesystem. Must be called one time before anything can be used!
Args:
mode
- Mode how to create the FS
Return:
()
- Init was successfulFsStatus::ErrorFsAlreadyInit
- FS is already initializedFsStatus::ErrorCreateFs
- Could not create FSFsStatus::ErrorSetupFs
- Could not setup FSFsStatus::ErrorInsertFsMeta
- Could not insert FS metadata into FS
Behavior:
-
If
mode == FsMode::Memory
the FS will be created in memory only. Nothing will be written to disk automatically. If you want to save your memory FS you need to callSqliteFs::save_memory_fs_to_disk
. -
If
mode == FsMode::Persist(fs_path)
and the FS specified byfs_path
does not exist then the FS will be created. When the FS already exist it will be loaded.
Sourcepub async fn close()
pub async fn close()
Close the FS
Behavior: Will set the global FS to None and the init lock to false.
Sourcepub async fn save_memory_fs_to_disk(fs_path: &str) -> Result<(), FsStatus>
pub async fn save_memory_fs_to_disk(fs_path: &str) -> Result<(), FsStatus>
Saves a Memory FS to disk
Args:
fs_path
- Path where the FS should be created.
Return:
()
- Save was successfulFsStatus::ErrorFsNotInit
- FS is not initializedFsStatus::ErrorDumpMemFs
- Could not get data from in-memory FSFsStatus::ErrorCreateFs
- Could not create FS on diskFsStatus::ErrorSetupFs
- Could not setup disk FSFsStatus::ErrorInsertFsMeta
- Could not insert FS metadata into disk FSFsStatus::ErrorSaveMemFsToDisk
- Could not write data to Disk
Behavior: Will update the FS Entry in the following way:
last_meta_read = datetime('now', 'localtime', 'subsec')
last_data_read = datetime('now', 'localtime', 'subsec')
Sourcepub fn get_fs_path(&self) -> String
pub fn get_fs_path(&self) -> String
Sourcepub async fn delete(f_name: &str) -> Result<(), FsStatus>
pub async fn delete(f_name: &str) -> Result<(), FsStatus>
Deletes a file directly and permanently from the FS. There is no trash where the files is moved to. When it’s gone, it’s gone!
Args:
f_name
- Name of the file to delete
Return:
()
- deletion was successfulFsStatus::ErrorFsNotInit
- FS is not initializedFsStatus::ErrorDelete
- There was some other error
Sourcepub async fn truncate(f_name: &str) -> Result<(), FsStatus>
pub async fn truncate(f_name: &str) -> Result<(), FsStatus>
Truncates the content of a file
Args:
f_name
- name of the file to truncate
Return:
()
- truncation was successfulFsStatus::ErrorFsNotInit
- FS is not initializedFsStatus::ErrorTruncate
- There was some other error
Behavior: Will update the FS Entry in the following way:
size = 0,
compress = FALSE,
size_compressed = NULL,
data = NULL,
sha = NULL
sha_compressed = NULL
last_modify = datetime('now', 'localtime', 'subsec'),
Sourcepub async fn get_filename_list() -> Result<Vec<String>, FsStatus>
pub async fn get_filename_list() -> Result<Vec<String>, FsStatus>
Returns a list of all filenames
Return:
Vec<String>
- a list of filenames that were deletedFsStatus::ErrorFsNotInit
- FS is not initializedFsStatus::ErrorGetFileNameList
- There was some other error
Sourcepub async fn delete_zero_sized_files() -> Result<Vec<String>, FsStatus>
pub async fn delete_zero_sized_files() -> Result<Vec<String>, FsStatus>
Delete all files with a size of 0 (zero)
Return:
Vec<String>
- a list of filenames that were deletedFsStatus::ErrorFsNotInit
- FS is not initializedFsStatus::ErrorDeleteFile
- There was some other error
Auto Trait Implementations§
impl Freeze for SqliteFs
impl !RefUnwindSafe for SqliteFs
impl Send for SqliteFs
impl Sync for SqliteFs
impl Unpin for SqliteFs
impl !UnwindSafe for SqliteFs
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
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>
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>
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