pub struct File { /* private fields */ }
Expand description
Text
Implementations§
Source§impl File
impl File
Sourcepub async fn create(f_name: &str) -> Result<Self, FsStatus>
pub async fn create(f_name: &str) -> Result<Self, FsStatus>
Creates a new file inside the FS
Args:
f_name
- Name of the File
Return:
Ok(Self)
- File was creates successfulErr(FsStatus::ErrorFsNotInit)
- FS is not initializedErr(FsStatus::ErrorFileExist(msg))
- Could not create file because a file with this name already existErr(FsStatus::ErrorCreateFile(msg))
- Could not create file because there was some other errorErr(FsStatus::ErrorUnknown(msg))
- Could not create file because there was some unknown error
Sourcepub async fn rename(&mut self, new_f_name: &str) -> Result<(), FsStatus>
pub async fn rename(&mut self, new_f_name: &str) -> Result<(), FsStatus>
Rename the current file
Args:
new_f_name
- new Name of the File
Return:
Ok(Self)
- File was creates successfulErr(FsStatus::ErrorFsNotInit)
- FS is not initializedErr(FsStatus::ErrorTransaction(msg))
- DB Transaction ErrorErr(FsStatus::ErrorFileExist(msg))
- Could not create file because a file with the new name already existErr(FsStatus::ErrorCreateFile(msg))
- Could not create file because there was some other errorErr(FsStatus::ErrorUnknown(msg))
- Could not create file because there was some unknown error
Sourcepub async fn write(&mut self, data: &[u8]) -> Result<(), FsStatus>
pub async fn write(&mut self, data: &[u8]) -> Result<(), FsStatus>
Behavior:
Args:
- `` -
Return:
- `` -
Sourcepub async fn truncate(&mut self) -> Result<(), FsStatus>
pub async fn truncate(&mut self) -> Result<(), FsStatus>
Truncates the content of the current file
Return:
Ok(())
- truncation was successfulErr(FsStatus::ErrorFsNotInit)
- FS is not initializedErr(FsStatus::ErrorTruncate(msg))
- 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 read_to_string(&self, dest: &mut String) -> Result<(), FsStatus>
pub async fn read_to_string(&self, dest: &mut String) -> Result<(), FsStatus>
Behavior:
Args:
- `` -
Return:
- `` -
Sourcepub async fn read_to_vec(&self, dest: &mut Vec<u8>) -> Result<(), FsStatus>
pub async fn read_to_vec(&self, dest: &mut Vec<u8>) -> Result<(), FsStatus>
Behavior:
Args:
- `` -
Return:
- `` -
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Return the name of the file
Return:
String
- name of the current file
Sourcepub fn size(&self) -> i64
pub fn size(&self) -> i64
Size of the uncompressed filecontent in bytes
Return:
i64
- size in bytes
Sourcepub fn sha(&self) -> Option<String>
pub fn sha(&self) -> Option<String>
Returns the BASE64 encoded SHA512 of the filecontent
Return:
Option<String>
- BASE64 encoded SHA512
Sourcepub fn sha_compressed(&self) -> Option<String>
pub fn sha_compressed(&self) -> Option<String>
Returns the BASE64 encoded SHA512 of the compressed filecontent
Return:
Option<String>
- BASE64 encoded SHA512
Trait Implementations§
Source§impl<'a, R: Row> FromRow<'a, R> for Filewhere
&'a str: ColumnIndex<R>,
i64: Decode<'a, R::Database> + Type<R::Database>,
String: Decode<'a, R::Database> + Type<R::Database>,
Option<String>: Decode<'a, R::Database> + Type<R::Database>,
u32: Decode<'a, R::Database> + Type<R::Database>,
Option<i64>: Decode<'a, R::Database> + Type<R::Database>,
impl<'a, R: Row> FromRow<'a, R> for Filewhere
&'a str: ColumnIndex<R>,
i64: Decode<'a, R::Database> + Type<R::Database>,
String: Decode<'a, R::Database> + Type<R::Database>,
Option<String>: Decode<'a, R::Database> + Type<R::Database>,
u32: Decode<'a, R::Database> + Type<R::Database>,
Option<i64>: Decode<'a, R::Database> + Type<R::Database>,
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
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