Skip to main content

revolt_database/models/file_hashes/
ops.rs

1use revolt_result::Result;
2
3use crate::FileHash;
4
5#[cfg(feature = "mongodb")]
6mod mongodb;
7mod reference;
8
9#[async_trait]
10pub trait AbstractAttachmentHashes: Sync + Send {
11    /// Insert a new attachment hash into the database.
12    async fn insert_attachment_hash(&self, hash: &FileHash) -> Result<()>;
13
14    /// Fetch an attachment hash entry by sha256 hash.
15    async fn fetch_attachment_hash(&self, hash: &str) -> Result<FileHash>;
16
17    /// Update an attachment hash nonce value.
18    async fn set_attachment_hash_nonce(&self, hash: &str, nonce: &str) -> Result<()>;
19
20    /// Updates the attachments animated metadata value.
21    ///
22    /// The primary use for this is to update the metadata for existing uploaded files, this
23    /// can only be used for images.
24    async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()>;
25
26    /// Delete attachment hash by id.
27    async fn delete_attachment_hash(&self, id: &str) -> Result<()>;
28}