summaryrefslogblamecommitdiffstats
path: root/src/file.rs
blob: 15d457a758d8fd6a853aa03d732ed14131502f3c (plain) (tree)
1
2
3
4



                        



























                                                                
 
use uuid::Uuid;

#[derive(sqlx::FromRow)]
pub struct File {
    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
    }
}