use crate::{PostgresError, PostgresStore};
use derive_more::Debug;
use futures::{Stream, stream};
use rdf_model::{HeapQuad, HeapQuadPattern, HeapTerm, StatementPattern};
use rdf_store::{ReadTransaction, WriteTransaction};
#[cfg_attr(doc, aquamarine::aquamarine)]
#[derive(Debug)]
pub struct PostgresTransaction {
pub writable: bool,
}
impl PostgresTransaction {
pub async fn begin(_store: &PostgresStore, writable: bool) -> Result<Self, PostgresError> {
Ok(Self { writable })
}
pub fn is_writable(&self) -> bool {
self.writable
}
}
impl WriteTransaction for PostgresTransaction {
type Error = PostgresError;
type Term = HeapTerm; type Statement = HeapQuad; type StatementPattern = HeapQuadPattern;
async fn rollback(self) -> Result<(), Self::Error> {
Ok(()) }
async fn commit(self) -> Result<(), Self::Error> {
Ok(()) }
async fn clear(&mut self) -> Result<(), Self::Error> {
Ok(()) }
async fn insert(
&mut self,
_statement: impl Into<Self::Statement> + Send,
) -> Result<(), Self::Error> {
Ok(()) }
async fn remove(
&mut self,
_statement: impl Into<Self::Statement> + Send,
) -> Result<(), Self::Error> {
Ok(()) }
async fn delete(
&mut self,
_pattern: impl Into<Self::StatementPattern> + Send,
) -> Result<(), Self::Error> {
Ok(()) }
}
impl ReadTransaction for PostgresTransaction {
type Error = PostgresError;
type Term = HeapTerm; type Statement = HeapQuad; type StatementPattern = HeapQuadPattern;
fn r#match(
&self,
_pattern: impl Into<Self::StatementPattern>,
) -> impl Stream<Item = Result<Self::Statement, Self::Error>> {
stream::empty() }
}