rdf_store_postgres/
transaction.rs1use crate::{PostgresError, PostgresStore};
4use derive_more::Debug;
5use futures::{Stream, stream};
6use rdf_model::{HeapQuad, HeapQuadPattern, HeapTerm, StatementPattern};
7use rdf_store::{ReadTransaction, WriteTransaction};
8
9#[cfg_attr(doc, aquamarine::aquamarine)]
10#[derive(Debug)]
12pub struct PostgresTransaction {
13 pub writable: bool,
14}
15
16impl PostgresTransaction {
17 pub async fn begin(_store: &PostgresStore, writable: bool) -> Result<Self, PostgresError> {
18 Ok(Self { writable })
20 }
21
22 pub fn is_writable(&self) -> bool {
23 self.writable
24 }
25}
26
27impl WriteTransaction for PostgresTransaction {
28 type Error = PostgresError;
29 type Term = HeapTerm; type Statement = HeapQuad; type StatementPattern = HeapQuadPattern; async fn rollback(self) -> Result<(), Self::Error> {
34 Ok(()) }
36
37 async fn commit(self) -> Result<(), Self::Error> {
38 Ok(()) }
40
41 async fn clear(&mut self) -> Result<(), Self::Error> {
42 Ok(()) }
44
45 async fn insert(
46 &mut self,
47 _statement: impl Into<Self::Statement> + Send,
48 ) -> Result<(), Self::Error> {
49 Ok(()) }
51
52 async fn remove(
53 &mut self,
54 _statement: impl Into<Self::Statement> + Send,
55 ) -> Result<(), Self::Error> {
56 Ok(()) }
58
59 async fn delete(
60 &mut self,
61 _pattern: impl Into<Self::StatementPattern> + Send,
62 ) -> Result<(), Self::Error> {
63 Ok(()) }
65}
66
67impl ReadTransaction for PostgresTransaction {
68 type Error = PostgresError;
69 type Term = HeapTerm; type Statement = HeapQuad; type StatementPattern = HeapQuadPattern; fn r#match(
74 &self,
75 _pattern: impl Into<Self::StatementPattern>,
76 ) -> impl Stream<Item = Result<Self::Statement, Self::Error>> {
77 stream::empty() }
79}