You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mediarepo/mediarepo-daemon/mediarepo-model/src/thumbnail.rs

22 lines
613 B
Rust

use mediarepo_core::error::RepoResult;
use mediarepo_core::fs::thumbnail_store::Dimensions;
use std::path::PathBuf;
use tokio::fs::{File, OpenOptions};
use tokio::io::BufReader;
pub struct Thumbnail {
pub file_hash: String,
pub path: PathBuf,
pub size: Dimensions,
pub mime_type: String,
}
impl Thumbnail {
/// Returns the reader of the thumbnail file
#[tracing::instrument(level = "debug", skip(self))]
pub async fn get_reader(&self) -> RepoResult<BufReader<File>> {
let file = OpenOptions::new().read(true).open(&self.path).await?;
Ok(BufReader::new(file))
}
}