Skip to main content

rdf_store/
write_transaction.rs

1// This is free and unencumbered software released into the public domain.
2
3use rdf_model::{Statement, StatementPattern, Term};
4
5/// A read-write (R/W) transaction on a [`Store`].
6pub trait WriteTransaction {
7    type Error;
8    type Term: Term + Clone;
9    type Statement: Statement<Term = Self::Term>;
10    type StatementPattern: StatementPattern<Term = Self::Term>;
11
12    /// Aborts the transaction, discarding any changes.
13    fn rollback(self) -> impl Future<Output = Result<(), Self::Error>>;
14
15    /// Commits the transaction, applying all changes.
16    fn commit(self) -> impl Future<Output = Result<(), Self::Error>>;
17
18    /// Clears all data from the store.
19    fn clear(&mut self) -> impl Future<Output = Result<(), Self::Error>>;
20
21    /// Inserts a statement into the store.
22    fn insert(
23        &mut self,
24        statement: impl Into<Self::Statement> + Send,
25    ) -> impl Future<Output = Result<(), Self::Error>>;
26
27    /// Removes a statement from the store.
28    fn remove(
29        &mut self,
30        statement: impl Into<Self::Statement> + Send,
31    ) -> impl Future<Output = Result<(), Self::Error>>;
32
33    /// Deletes all statements matching the given statement pattern.
34    fn delete(
35        &mut self,
36        pattern: impl Into<Self::StatementPattern> + Send,
37    ) -> impl Future<Output = Result<(), Self::Error>>;
38}