pub struct PartitionConnection { /* private fields */ }Expand description
A connection to a partition SQLite database
Implementations§
Source§impl PartitionConnection
impl PartitionConnection
Sourcepub fn open(path: &Path, partition_id: &str) -> Result<Self, PartitionError>
pub fn open(path: &Path, partition_id: &str) -> Result<Self, PartitionError>
Open an existing partition database
If the partition is at an older schema version (v1.0), it will be automatically migrated to the current version (v1.1).
Sourcepub fn create(path: &Path, partition_id: &str) -> Result<Self, PartitionError>
pub fn create(path: &Path, partition_id: &str) -> Result<Self, PartitionError>
Create a new partition database with schema
Sourcepub fn in_memory(partition_id: &str) -> Result<Self, PartitionError>
pub fn in_memory(partition_id: &str) -> Result<Self, PartitionError>
Create an in-memory partition database (for testing)
Sourcepub fn partition_id(&self) -> &str
pub fn partition_id(&self) -> &str
Get the partition ID
Sourcepub fn get_metadata(&self, key: &str) -> Result<Option<String>, PartitionError>
pub fn get_metadata(&self, key: &str) -> Result<Option<String>, PartitionError>
Get a metadata value
Sourcepub fn set_metadata(&self, key: &str, value: &str) -> Result<(), PartitionError>
pub fn set_metadata(&self, key: &str, value: &str) -> Result<(), PartitionError>
Set a metadata value
Sourcepub fn insert_node(&self, node: &Node) -> Result<(), PartitionError>
pub fn insert_node(&self, node: &Node) -> Result<(), PartitionError>
Insert a node into the partition
Sourcepub fn insert_nodes(&self, nodes: &[Node]) -> Result<(), PartitionError>
pub fn insert_nodes(&self, nodes: &[Node]) -> Result<(), PartitionError>
Insert multiple nodes in a transaction
Sourcepub fn query_nodes_by_file(
&self,
file: &str,
) -> Result<Vec<Node>, PartitionError>
pub fn query_nodes_by_file( &self, file: &str, ) -> Result<Vec<Node>, PartitionError>
Query nodes by file path
Sourcepub fn query_all_nodes(&self) -> Result<Vec<Node>, PartitionError>
pub fn query_all_nodes(&self) -> Result<Vec<Node>, PartitionError>
Query all nodes in the partition
Sourcepub fn delete_nodes_by_file(&self, file: &str) -> Result<usize, PartitionError>
pub fn delete_nodes_by_file(&self, file: &str) -> Result<usize, PartitionError>
Delete nodes by file path
Sourcepub fn delete_node(&self, id: &str) -> Result<bool, PartitionError>
pub fn delete_node(&self, id: &str) -> Result<bool, PartitionError>
Delete a node by ID
Sourcepub fn node_count(&self) -> Result<usize, PartitionError>
pub fn node_count(&self) -> Result<usize, PartitionError>
Get node count
Sourcepub fn insert_edge(&self, edge: &Edge) -> Result<(), PartitionError>
pub fn insert_edge(&self, edge: &Edge) -> Result<(), PartitionError>
Insert an edge into the partition
Sourcepub fn insert_edges(&self, edges: &[Edge]) -> Result<(), PartitionError>
pub fn insert_edges(&self, edges: &[Edge]) -> Result<(), PartitionError>
Insert multiple edges in a transaction
Sourcepub fn query_edges_by_source(
&self,
source: &str,
) -> Result<Vec<Edge>, PartitionError>
pub fn query_edges_by_source( &self, source: &str, ) -> Result<Vec<Edge>, PartitionError>
Query edges by source node ID
Sourcepub fn query_edges_by_target(
&self,
target: &str,
) -> Result<Vec<Edge>, PartitionError>
pub fn query_edges_by_target( &self, target: &str, ) -> Result<Vec<Edge>, PartitionError>
Query edges by target node ID
Sourcepub fn query_all_edges(&self) -> Result<Vec<Edge>, PartitionError>
pub fn query_all_edges(&self) -> Result<Vec<Edge>, PartitionError>
Query all edges in the partition
Sourcepub fn delete_edges_involving(
&self,
node_id: &str,
) -> Result<usize, PartitionError>
pub fn delete_edges_involving( &self, node_id: &str, ) -> Result<usize, PartitionError>
Delete edges involving a node (as source or target)
Sourcepub fn delete_edges_by_source(
&self,
source: &str,
) -> Result<usize, PartitionError>
pub fn delete_edges_by_source( &self, source: &str, ) -> Result<usize, PartitionError>
Delete edges by source node
Sourcepub fn edge_count(&self) -> Result<usize, PartitionError>
pub fn edge_count(&self) -> Result<usize, PartitionError>
Get edge count
Sourcepub fn clear(&self) -> Result<(), PartitionError>
pub fn clear(&self) -> Result<(), PartitionError>
Clear all data from the partition (keeps schema)
Sourcepub fn stats(&self) -> Result<PartitionStats, PartitionError>
pub fn stats(&self) -> Result<PartitionStats, PartitionError>
Get partition statistics
Auto Trait Implementations§
impl !Freeze for PartitionConnection
impl !RefUnwindSafe for PartitionConnection
impl Send for PartitionConnection
impl !Sync for PartitionConnection
impl Unpin for PartitionConnection
impl !UnwindSafe for PartitionConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more