pub struct AsyncGraph { /* private fields */ }Expand description
Async handle to a knowledge graph backed by a rusqlite::Connection.
Internally wraps the connection in Arc<Mutex<_>> so it can be shared
across async tasks. All blocking SQL calls are offloaded to the Tokio
blocking-thread pool.
Implementations§
Source§impl AsyncGraph
impl AsyncGraph
Sourcepub fn new(conn: Connection) -> Self
pub fn new(conn: Connection) -> Self
Wrap an already-initialised connection.
Sourcepub async fn open(path: impl Into<String>) -> Result<Self>
pub async fn open(path: impl Into<String>) -> Result<Self>
Open (or create) a database at path and initialise the graph schema.
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 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 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 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>>
Run smart recall with composite scoring.
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 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 AsyncGraph
impl Clone for AsyncGraph
Source§fn clone(&self) -> AsyncGraph
fn clone(&self) -> AsyncGraph
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AsyncGraph
impl RefUnwindSafe for AsyncGraph
impl Send for AsyncGraph
impl Sync for AsyncGraph
impl Unpin for AsyncGraph
impl UnsafeUnpin for AsyncGraph
impl UnwindSafe for AsyncGraph
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>
Wrap the input message
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.