pub struct File {
pub id: Uuid,
pub name: String,
pub mime: String,
pub folder_id: Uuid,
pub parent_id: Option<Uuid>,
pub hash: String,
pub size: i32,
pub encrypted: bool,
pub pinned: bool,
pub file_key: String,
pub created_at: DateTime<Utc>,
pub created_by: Option<String>,
}Fields§
§id: UuidUnique identifier for the file
name: StringName of the file
mime: StringMime type of the file content
folder_id: UuidParent folder ID
parent_id: Option<Uuid>Optional parent file ID if the file is a child of some other file (i.e attachment for an email file)
hash: StringHash of the file bytes stored in S3
size: i32Size of the file in bytes
encrypted: boolWhether the file was determined to be encrypted when processing
pinned: boolWhether the file is marked as pinned
file_key: StringS3 key pointing to the file
created_at: DateTime<Utc>When the file was created
created_by: Option<String>User who created the file
Implementations§
Source§impl File
impl File
pub async fn create( db: impl PgExecutor<'_>, __arg1: CreateFile, ) -> Result<File, Error>
pub async fn all( db: impl PgExecutor<'_>, offset: u64, page_size: u64, ) -> Result<Vec<FileWithScope>, Error>
pub async fn move_to_folder( self, db: impl PgExecutor<'_>, folder_id: Uuid, ) -> Result<File, Error>
pub async fn rename( self, db: impl PgExecutor<'_>, name: String, ) -> Result<File, Error>
Sourcepub async fn set_pinned(
self,
db: impl PgExecutor<'_>,
pinned: bool,
) -> Result<File, Error>
pub async fn set_pinned( self, db: impl PgExecutor<'_>, pinned: bool, ) -> Result<File, Error>
Updates the pinned state of the file
Sourcepub async fn set_encrypted(
self,
db: impl PgExecutor<'_>,
encrypted: bool,
) -> Result<File, Error>
pub async fn set_encrypted( self, db: impl PgExecutor<'_>, encrypted: bool, ) -> Result<File, Error>
Updates the encryption state of the file
Sourcepub async fn set_mime(
self,
db: impl PgExecutor<'_>,
mime: String,
) -> Result<File, Error>
pub async fn set_mime( self, db: impl PgExecutor<'_>, mime: String, ) -> Result<File, Error>
Updates the mime type of a file
pub async fn all_by_mime( db: impl PgExecutor<'_>, mime: &str, offset: u64, page_size: u64, ) -> Result<Vec<FileWithScope>, Error>
pub async fn all_by_mimes( db: impl PgExecutor<'_>, mimes: &[&str], offset: u64, page_size: u64, ) -> Result<Vec<FileWithScope>, Error>
Sourcepub async fn find(
db: impl PgExecutor<'_>,
scope: &String,
file_id: Uuid,
) -> Result<Option<File>, Error>
pub async fn find( db: impl PgExecutor<'_>, scope: &String, file_id: Uuid, ) -> Result<Option<File>, Error>
Finds a specific file using its full path scope -> folder -> file
Sourcepub async fn resolve_path(
db: impl PgExecutor<'_>,
file_id: Uuid,
) -> Result<Vec<FolderPathSegment>, Error>
pub async fn resolve_path( db: impl PgExecutor<'_>, file_id: Uuid, ) -> Result<Vec<FolderPathSegment>, Error>
Collects the IDs and names of all parent folders of the provided folder
pub async fn find_by_parent( db: impl PgExecutor<'_>, parent_id: Uuid, ) -> Result<Vec<File>, Error>
Sourcepub async fn delete(
&self,
db: impl PgExecutor<'_>,
) -> Result<PgQueryResult, Error>
pub async fn delete( &self, db: impl PgExecutor<'_>, ) -> Result<PgQueryResult, Error>
Deletes the file
Sourcepub async fn resolve_with_extra(
db: impl PgExecutor<'_>,
scope: &String,
file_ids: Vec<Uuid>,
) -> Result<Vec<WithFullPath<FileWithExtra>>, Error>
pub async fn resolve_with_extra( db: impl PgExecutor<'_>, scope: &String, file_ids: Vec<Uuid>, ) -> Result<Vec<WithFullPath<FileWithExtra>>, Error>
Finds a collection of files that are all within the same document box, resolves both the files themselves and the folder path to traverse to get to each file
Sourcepub async fn resolve_with_extra_mixed_scopes(
db: impl PgExecutor<'_>,
files_scope_with_id: Vec<DocboxInputPair<'_>>,
) -> Result<Vec<WithFullPathScope<FileWithExtra>>, Error>
pub async fn resolve_with_extra_mixed_scopes( db: impl PgExecutor<'_>, files_scope_with_id: Vec<DocboxInputPair<'_>>, ) -> Result<Vec<WithFullPathScope<FileWithExtra>>, Error>
Finds a collection of files that are within various document box scopes, resolves both the files themselves and the folder path to traverse to get to each file
Sourcepub async fn find_with_extra(
db: impl PgExecutor<'_>,
scope: &String,
file_id: Uuid,
) -> Result<Option<FileWithExtra>, Error>
pub async fn find_with_extra( db: impl PgExecutor<'_>, scope: &String, file_id: Uuid, ) -> Result<Option<FileWithExtra>, Error>
Finds a specific file using its full path scope -> folder -> file fetching the additional details about the file like the creator and last modified
pub async fn find_by_parent_folder_with_extra( db: impl PgExecutor<'_>, parent_id: Uuid, ) -> Result<Vec<FileWithExtra>, Error>
pub async fn find_by_parent_file_with_extra( db: impl PgExecutor<'_>, parent_id: Uuid, ) -> Result<Vec<FileWithExtra>, Error>
Sourcepub async fn total_count(db: impl PgExecutor<'_>) -> Result<i64, Error>
pub async fn total_count(db: impl PgExecutor<'_>) -> Result<i64, Error>
Get the total number of files in the tenant
Sourcepub async fn total_size(db: impl PgExecutor<'_>) -> Result<i64, Error>
pub async fn total_size(db: impl PgExecutor<'_>) -> Result<i64, Error>
Get the total “size” of files within the current tenant, this does not include the size of generated files
Sourcepub async fn total_size_within_scope(
db: impl PgExecutor<'_>,
scope: &str,
) -> Result<i64, Error>
pub async fn total_size_within_scope( db: impl PgExecutor<'_>, scope: &str, ) -> Result<i64, Error>
Get the total “size” of files within a specific scope, this does not include the size of generated files
Trait Implementations§
Source§impl<'q> Encode<'_, Postgres> for File
impl<'q> Encode<'_, Postgres> for File
Source§fn encode_by_ref(
&self,
buf: &mut PgArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn size_hint(&self) -> usize
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
Source§impl<'a, R> FromRow<'a, R> for Filewhere
R: Row,
&'a str: ColumnIndex<R>,
Uuid: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
String: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<Uuid>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
i32: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
bool: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
DateTime<Utc>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<String>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
impl<'a, R> FromRow<'a, R> for Filewhere
R: Row,
&'a str: ColumnIndex<R>,
Uuid: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
String: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<Uuid>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
i32: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
bool: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
DateTime<Utc>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Option<String>: Decode<'a, <R as Row>::Database> + Type<<R as Row>::Database>,
Source§impl PgHasArrayType for File
impl PgHasArrayType for File
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl Serialize for File
impl Serialize for File
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for File
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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