pub trait DatabaseOperationHandler: Send + Sync {
Show 13 methods
// Required methods
fn execute_sql(&self, sql: &str) -> Result<Vec<u8>, String>;
fn insert_document(
&self,
collection: &str,
document: &[u8],
) -> Result<String, String>;
fn update_document(
&self,
collection: &str,
doc_id: &str,
document: &[u8],
) -> Result<(), String>;
fn delete_document(
&self,
collection: &str,
doc_id: &str,
) -> Result<(), String>;
fn create_node(
&self,
label: &str,
properties: &[u8],
) -> Result<String, String>;
fn delete_node(&self, node_id: &str) -> Result<(), String>;
fn create_edge(
&self,
edge_type: &str,
from_node: &str,
to_node: &str,
properties: &[u8],
) -> Result<String, String>;
fn delete_edge(&self, edge_id: &str) -> Result<(), String>;
fn begin_transaction(&self, tx_id: u64) -> Result<(), String>;
fn commit_transaction(&self, tx_id: u64) -> Result<(), String>;
fn rollback_transaction(&self, tx_id: u64) -> Result<(), String>;
fn create_snapshot(&self) -> Result<Vec<u8>, String>;
fn restore_snapshot(&self, data: &[u8]) -> Result<(), String>;
}Expand description
Trait for handling database operations. Implement this to connect Raft replication to your storage layer.
Required Methods§
Sourcefn insert_document(
&self,
collection: &str,
document: &[u8],
) -> Result<String, String>
fn insert_document( &self, collection: &str, document: &[u8], ) -> Result<String, String>
Insert a document into a collection.
Sourcefn update_document(
&self,
collection: &str,
doc_id: &str,
document: &[u8],
) -> Result<(), String>
fn update_document( &self, collection: &str, doc_id: &str, document: &[u8], ) -> Result<(), String>
Update a document in a collection.
Sourcefn delete_document(&self, collection: &str, doc_id: &str) -> Result<(), String>
fn delete_document(&self, collection: &str, doc_id: &str) -> Result<(), String>
Delete a document from a collection.
Sourcefn create_node(&self, label: &str, properties: &[u8]) -> Result<String, String>
fn create_node(&self, label: &str, properties: &[u8]) -> Result<String, String>
Create a graph node.
Sourcefn create_edge(
&self,
edge_type: &str,
from_node: &str,
to_node: &str,
properties: &[u8],
) -> Result<String, String>
fn create_edge( &self, edge_type: &str, from_node: &str, to_node: &str, properties: &[u8], ) -> Result<String, String>
Create a graph edge.