use super::blobref::BlobRef; use crate::common::mime::MimeType; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; #[derive(Debug)] pub(super) struct Attrs { pub name: Option, pub group: Option, pub mime: Option, pub created_at: Option, pub updated_at: Option, pub deleted_at: Option, pub tags: Vec, pub note: Option, } #[derive(Debug, Serialize, Deserialize)] pub(super) struct Chunk { pub size: usize, pub offset: usize, pub blobref: BlobRef, } #[derive(Debug)] pub struct Object { pub(super) blobref: BlobRef, pub(super) size: usize, pub(super) chunks: Vec, pub(super) attrs: Attrs, pub(super) created_at: Option, pub(super) updated_at: Option, } impl Object { pub fn blobref(&self) -> &BlobRef { &self.blobref } pub fn size(&self) -> usize { self.size } pub fn is_group(&self) -> bool { matches!(self.attrs.mime, Some(MimeType::ApplicationXGroup)) } pub fn get_name(&self) -> Option { self.attrs.name.clone() } }