diff options
author | 2024-11-14 17:59:21 +0000 | |
---|---|---|
committer | 2024-11-14 17:59:21 +0000 | |
commit | 469a3ad33914f7eff6edc9ca7fabb12f2950da84 (patch) | |
tree | 2712ba2e927fb820b6aa58443c9227d1da24a03f /src/file.rs | |
parent | b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6 (diff) | |
download | critch-469a3ad33914f7eff6edc9ca7fabb12f2950da84.tar.gz critch-469a3ad33914f7eff6edc9ca7fabb12f2950da84.tar.bz2 critch-469a3ad33914f7eff6edc9ca7fabb12f2950da84.zip |
database work
Diffstat (limited to 'src/file.rs')
-rw-r--r-- | src/file.rs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/file.rs b/src/file.rs index 8a49839..15d457a 100644 --- a/src/file.rs +++ b/src/file.rs @@ -2,6 +2,32 @@ use uuid::Uuid; #[derive(sqlx::FromRow)] pub struct File { - id: Option<Uuid>, - artwork: usize, + id: Uuid, + pub alt_text: String, + extension: String, + artwork_id: Option<i32>, +} + +impl File { + pub fn new(file: std::fs::File, extension: String) -> Self { + let id = Uuid::new_v4(); + Self { + id, + alt_text: String::new(), + extension, + artwork_id: None, + } + } + + pub fn id(&self) -> Uuid { + self.id + } + + pub fn extension(&self) -> &str { + &self.extension + } + + pub fn artwork_id(&self) -> Option<i32> { + self.artwork_id + } } |