Skip to main content

DatabaseOperationHandler

Trait DatabaseOperationHandler 

Source
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§

Source

fn execute_sql(&self, sql: &str) -> Result<Vec<u8>, String>

Execute a SQL statement.

Source

fn insert_document( &self, collection: &str, document: &[u8], ) -> Result<String, String>

Insert a document into a collection.

Source

fn update_document( &self, collection: &str, doc_id: &str, document: &[u8], ) -> Result<(), String>

Update a document in a collection.

Source

fn delete_document(&self, collection: &str, doc_id: &str) -> Result<(), String>

Delete a document from a collection.

Source

fn create_node(&self, label: &str, properties: &[u8]) -> Result<String, String>

Create a graph node.

Source

fn delete_node(&self, node_id: &str) -> Result<(), String>

Delete a graph node.

Source

fn create_edge( &self, edge_type: &str, from_node: &str, to_node: &str, properties: &[u8], ) -> Result<String, String>

Create a graph edge.

Source

fn delete_edge(&self, edge_id: &str) -> Result<(), String>

Delete a graph edge.

Source

fn begin_transaction(&self, tx_id: u64) -> Result<(), String>

Begin a transaction.

Source

fn commit_transaction(&self, tx_id: u64) -> Result<(), String>

Commit a transaction.

Source

fn rollback_transaction(&self, tx_id: u64) -> Result<(), String>

Rollback a transaction.

Source

fn create_snapshot(&self) -> Result<Vec<u8>, String>

Create a full snapshot of the database state.

Source

fn restore_snapshot(&self, data: &[u8]) -> Result<(), String>

Restore from a snapshot.

Implementors§