Skip to main content

core_crypto_keystore/transaction/
proteus.rs

1use crate::{CryptoKeystoreError, Transaction, entities::ProteusPrekey, traits::FetchFromDatabase};
2
3#[cfg_attr(target_os = "unknown", async_trait::async_trait(?Send))]
4#[cfg_attr(not(target_os = "unknown"), async_trait::async_trait)]
5impl proteus_traits::PreKeyStore for Transaction {
6    type Error = CryptoKeystoreError;
7
8    async fn prekey(&self, id: proteus_traits::RawPreKeyId) -> Result<Option<proteus_traits::RawPreKey>, Self::Error> {
9        FetchFromDatabase::get::<ProteusPrekey>(self, &id)
10            .await
11            .map(|maybe_prekey| maybe_prekey.map(|mut db_prekey| std::mem::take(&mut db_prekey.prekey)))
12    }
13
14    async fn remove(&self, id: proteus_traits::RawPreKeyId) -> Result<(), Self::Error> {
15        <Self>::remove::<ProteusPrekey>(self, &id).await
16    }
17}