1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::FileData;
use bson::oid::ObjectId;
use mime::Mime;
use chrono::prelude::*;
#[derive(Debug)]
pub struct FileItem {
pub(crate) id: ObjectId,
pub(crate) create_time: DateTime<Utc>,
pub(crate) expire_at: Option<DateTime<Utc>>,
pub(crate) mime_type: Mime,
pub(crate) file_size: u64,
pub(crate) file_name: String,
pub(crate) file_data: FileData,
}
impl FileItem {
pub fn get_object_id(&self) -> &ObjectId {
&self.id
}
pub fn get_create_time(&self) -> &DateTime<Utc> {
&self.create_time
}
pub fn get_expiration_time(&self) -> Option<&DateTime<Utc>> {
self.expire_at.as_ref()
}
pub fn get_mime_type(&self) -> &Mime {
&self.mime_type
}
pub fn get_file_size(&self) -> u64 {
self.file_size
}
pub fn get_file_name(&self) -> &str {
&self.file_name
}
pub fn into_file_data(self) -> FileData {
self.file_data
}
}