Skip to main content

holochain_data/dht/tx_operations/
entry.rs

1//! `TxRead<Dht>` / `TxWrite<Dht>` API for the `Entry` and `PrivateEntry` tables.
2
3use super::super::inner::entry;
4use crate::handles::{TxRead, TxWrite};
5use crate::kind::Dht;
6use holo_hash::{AgentPubKey, EntryHash};
7use holochain_integrity_types::entry::Entry;
8
9impl TxWrite<Dht> {
10    pub async fn insert_entry(&mut self, hash: &EntryHash, entry: &Entry) -> sqlx::Result<()> {
11        entry::insert_entry(self.conn_mut(), hash, entry).await
12    }
13
14    pub async fn insert_private_entry(
15        &mut self,
16        hash: &EntryHash,
17        author: &AgentPubKey,
18        entry: &Entry,
19    ) -> sqlx::Result<()> {
20        entry::insert_private_entry(self.conn_mut(), hash, author, entry).await
21    }
22}
23
24impl TxRead<Dht> {
25    /// Reads an entry by hash. Pass `author = Some(_)` to also surface a
26    /// matching `PrivateEntry` owned by that author.
27    pub async fn get_entry(
28        &mut self,
29        hash: EntryHash,
30        author: Option<&AgentPubKey>,
31    ) -> sqlx::Result<Option<Entry>> {
32        entry::get_entry(self.conn_mut(), hash, author).await
33    }
34}