pub struct AsyncPoolGraph { /* private fields */ }Expand description
Bounded async connection pool for the knowledge graph.
Uses a Semaphore to bound concurrency and a Mutex<Vec<Connection>>
for idle connection reuse. Each method acquires a permit, takes (or creates)
a connection, runs the operation via spawn_blocking, then returns the
connection to the pool.
Implementations§
Source§impl AsyncPoolGraph
impl AsyncPoolGraph
Sourcepub async fn open(path: impl AsRef<Path>, max_conns: usize) -> Result<Self>
pub async fn open(path: impl AsRef<Path>, max_conns: usize) -> Result<Self>
Open (or create) a database and initialise the graph schema.
max_conns bounds the number of concurrent operations.
Sourcepub async fn open_in_memory(max_conns: usize) -> Result<Self>
pub async fn open_in_memory(max_conns: usize) -> Result<Self>
Create an in-memory pool with schema applied. Useful for tests.
Uses SQLite shared-cache mode so all connections in the pool see the
same data (plain :memory: creates an independent DB per connection).
Sourcepub async fn upsert_node(&self, node: GraphNode) -> Result<()>
pub async fn upsert_node(&self, node: GraphNode) -> Result<()>
Insert or replace a node.
Sourcepub async fn read_node(
&self,
id: impl Into<String>,
) -> Result<Option<GraphNode>>
pub async fn read_node( &self, id: impl Into<String>, ) -> Result<Option<GraphNode>>
Read a node by ID. Returns None if not found.
Sourcepub async fn read_nodes(&self) -> Result<Vec<GraphNode>>
pub async fn read_nodes(&self) -> Result<Vec<GraphNode>>
Read all nodes (limited to 10 000).
Sourcepub async fn delete_node(&self, id: impl Into<String>) -> Result<bool>
pub async fn delete_node(&self, id: impl Into<String>) -> Result<bool>
Delete a node by ID. Returns true if a row was deleted.
Sourcepub async fn append_edge(&self, edge: GraphEdge) -> Result<()>
pub async fn append_edge(&self, edge: GraphEdge) -> Result<()>
Append an edge (duplicates by ID are ignored).
Sourcepub async fn read_edges(&self) -> Result<Vec<GraphEdge>>
pub async fn read_edges(&self) -> Result<Vec<GraphEdge>>
Read all edges (limited to 10 000).
Sourcepub async fn delete_edge(&self, id: impl Into<String>) -> Result<bool>
pub async fn delete_edge(&self, id: impl Into<String>) -> Result<bool>
Delete an edge by ID. Returns true if a row was deleted.
Sourcepub async fn search_nodes(
&self,
query: impl Into<String>,
limit: usize,
) -> Result<Vec<GraphNode>>
pub async fn search_nodes( &self, query: impl Into<String>, limit: usize, ) -> Result<Vec<GraphNode>>
Full-text search over node titles and bodies.
Sourcepub async fn smart_recall(
&self,
project: Option<String>,
hint: Option<String>,
limit: usize,
) -> Result<Vec<ScoredNode>>
pub async fn smart_recall( &self, project: Option<String>, hint: Option<String>, limit: usize, ) -> Result<Vec<ScoredNode>>
Smart recall with composite scoring.
Sourcepub async fn stats(&self) -> Result<GraphStats>
pub async fn stats(&self) -> Result<GraphStats>
Compute graph statistics (node/edge counts, avg importance).
Trait Implementations§
Source§impl Clone for AsyncPoolGraph
impl Clone for AsyncPoolGraph
Source§fn clone(&self) -> AsyncPoolGraph
fn clone(&self) -> AsyncPoolGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AsyncPoolGraph
impl RefUnwindSafe for AsyncPoolGraph
impl Send for AsyncPoolGraph
impl Sync for AsyncPoolGraph
impl Unpin for AsyncPoolGraph
impl UnsafeUnpin for AsyncPoolGraph
impl UnwindSafe for AsyncPoolGraph
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.