use std::path::PathBuf; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use url::Url; #[derive(Debug, Clone, Serialize, Deserialize)] pub enum StorageLocation { FileStore {path: PathBuf}, Link } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Image { pub filename: String, pub tags: Vec, pub create_date: DateTime, pub link: String, pub created_by: u64, pub storage_location: StorageLocation, id: Option } impl Image { pub fn new(filename: &str, tags: Vec, link: Url, created_by: u64, storage_location: StorageLocation) -> Self { Self { filename: filename.to_string(), tags, create_date: Utc::now(), link: link.to_string(), created_by, storage_location, id: None, } } } impl j_db::model::JdbModel for Image { fn id(&self) -> Option { self.id } fn set_id(&mut self, id: u64) { self.id = Some(id) } fn tree() -> String { "Image".to_string() } } #[derive(Debug, Clone, Serialize, Deserialize)] pub enum ImageData { Bytes(Vec), Link(String) }