Struct File

Source
pub struct File { /* private fields */ }
Expand description

Text

Implementations§

Source§

impl File

Source

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 successful
  • Err(FsStatus::ErrorFsNotInit) - FS is not initialized
  • Err(FsStatus::ErrorFileExist(msg)) - Could not create file because a file with this name already exist
  • Err(FsStatus::ErrorCreateFile(msg)) - Could not create file because there was some other error
  • Err(FsStatus::ErrorUnknown(msg)) - Could not create file because there was some unknown error
Source

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 successful
  • Err(FsStatus::ErrorFsNotInit) - FS is not initialized
  • Err(FsStatus::ErrorTransaction(msg)) - DB Transaction Error
  • Err(FsStatus::ErrorFileExist(msg)) - Could not create file because a file with the new name already exist
  • Err(FsStatus::ErrorCreateFile(msg)) - Could not create file because there was some other error
  • Err(FsStatus::ErrorUnknown(msg)) - Could not create file because there was some unknown error
Source

pub async fn open(f_name: &str) -> Result<File, FsStatus>

Behavior:

Args:

  • `` -

Return:

  • `` -
Source

pub async fn delete(self) -> Result<(), FsStatus>

Behavior:

Args:

  • `` -

Return:

  • `` -
Source

pub async fn write(&mut self, data: &[u8]) -> Result<(), FsStatus>

Behavior:

Args:

  • `` -

Return:

  • `` -
Source

pub async fn truncate(&mut self) -> Result<(), FsStatus>

Truncates the content of the current file

Return:

  • Ok(()) - truncation was successful
  • Err(FsStatus::ErrorFsNotInit) - FS is not initialized
  • Err(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'),
Source

pub async fn read_to_string(&self, dest: &mut String) -> Result<(), FsStatus>

Behavior:

Args:

  • `` -

Return:

  • `` -
Source

pub async fn read_to_vec(&self, dest: &mut Vec<u8>) -> Result<(), FsStatus>

Behavior:

Args:

  • `` -

Return:

  • `` -
Source

pub fn name(&self) -> &str

Return the name of the file

Return:

  • String - name of the current file
Source

pub fn size(&self) -> i64

Size of the uncompressed filecontent in bytes

Return:

  • i64 - size in bytes
Source

pub fn sha(&self) -> Option<String>

Returns the BASE64 encoded SHA512 of the filecontent

Return:

  • Option<String> - BASE64 encoded SHA512
Source

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 Debug for File

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, R: Row> FromRow<'a, R> for File
where &'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>,

Source§

fn from_row(__row: &'a R) -> Result<Self>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T