2025-03-16 17:40:55 +00:00
|
|
|
use ruma::ServerName;
|
|
|
|
use sha2::{digest::Output, Sha256};
|
2024-07-15 13:35:37 +02:00
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
use crate::Result;
|
|
|
|
|
2025-03-16 17:40:55 +00:00
|
|
|
use super::DbFileMeta;
|
|
|
|
|
2022-10-05 15:33:57 +02:00
|
|
|
pub trait Data: Send + Sync {
|
2022-10-05 20:34:31 +02:00
|
|
|
fn create_file_metadata(
|
|
|
|
&self,
|
2025-03-16 17:40:55 +00:00
|
|
|
sha256_digest: Output<Sha256>,
|
|
|
|
file_size: u64,
|
|
|
|
servername: &ServerName,
|
|
|
|
media_id: &str,
|
|
|
|
filename: Option<&str>,
|
|
|
|
content_type: Option<&str>,
|
|
|
|
) -> Result<()>;
|
|
|
|
|
|
|
|
fn search_file_metadata(&self, servername: &ServerName, media_id: &str) -> Result<DbFileMeta>;
|
|
|
|
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
fn create_thumbnail_metadata(
|
|
|
|
&self,
|
|
|
|
sha256_digest: Output<Sha256>,
|
|
|
|
file_size: u64,
|
|
|
|
servername: &ServerName,
|
|
|
|
media_id: &str,
|
2022-10-05 20:34:31 +02:00
|
|
|
width: u32,
|
|
|
|
height: u32,
|
2025-03-16 17:40:55 +00:00
|
|
|
filename: Option<&str>,
|
2022-10-05 20:34:31 +02:00
|
|
|
content_type: Option<&str>,
|
2025-03-16 17:40:55 +00:00
|
|
|
) -> Result<()>;
|
2022-09-07 13:25:51 +02:00
|
|
|
|
2025-03-16 17:40:55 +00:00
|
|
|
// Returns the sha256 hash, filename and content_type and whether the media should be accessible via
|
|
|
|
/// unauthenticated endpoints.
|
|
|
|
fn search_thumbnail_metadata(
|
2022-10-05 20:34:31 +02:00
|
|
|
&self,
|
2025-03-16 17:40:55 +00:00
|
|
|
servername: &ServerName,
|
|
|
|
media_id: &str,
|
2022-10-05 20:34:31 +02:00
|
|
|
width: u32,
|
|
|
|
height: u32,
|
2025-03-16 17:40:55 +00:00
|
|
|
) -> Result<DbFileMeta>;
|
2022-09-07 13:25:51 +02:00
|
|
|
}
|