Skip to main content

PgGraph

Struct PgGraph 

Source
pub struct PgGraph { /* private fields */ }
Expand description

PostgreSQL-backed GraphBackend over one mutex-guarded connection.

Opening applies the schema and runs pending migrations, matching SqliteGraph::open in the main crate.

Implementations§

Source§

impl PgGraph

Source

pub fn connect(url: &str) -> Result<Self>

Connect to url (libpq connstring or postgresql:// URL), apply schema and migrations, and return a ready backend.

Source

pub fn connect_config(config: &Config) -> Result<Self>

Connect from a pre-built Config (useful for overriding dbname, e.g. when targeting a throwaway test database).

Source

pub fn connect_tls<T>(url: &str, connector: T) -> Result<Self>
where T: MakeTlsConnect<Socket> + Send + 'static, T::TlsConnect: Send, T::Stream: Send, <T::TlsConnect as TlsConnect<Socket>>::Future: Send,

Connect to url using a caller-supplied TLS connector — for servers requiring sslmode=require or stricter (e.g. RDS with rds.force_ssl). See Self::connect_native_tls for the common case of a system-trust-store native-tls connector.

Source

pub fn connect_config_tls<T>(config: &Config, connector: T) -> Result<Self>
where T: MakeTlsConnect<Socket> + Send + 'static, T::TlsConnect: Send, T::Stream: Send, <T::TlsConnect as TlsConnect<Socket>>::Future: Send,

Connect from a pre-built Config using a caller-supplied TLS connector. Mirrors Self::connect_config but negotiates TLS instead of postgres::NoTls.

Source

pub fn connect_native_tls(url: &str) -> Result<Self>

Connect to url over TLS using native-tls with the system trust store (default settings — full certificate chain and hostname verification against the system trust store, not weakened) — covers the common case of a Postgres server with a publicly-trusted certificate (e.g. RDS sslmode=require). For custom CA bundles or client certificates, build a connector and call Self::connect_tls directly.

Source

pub fn list_nodes(&self, limit: usize) -> Result<Vec<GraphNode>>

List up to limit nodes (uncapped — unlike GraphBackend::query_nodes, which is capped at 200). Used by the migration CLI to enumerate a source backend of arbitrary size.

Source

pub fn list_edges(&self, limit: usize) -> Result<Vec<GraphEdge>>

List up to limit edges (uncapped).

Trait Implementations§

Source§

impl GraphBackend for PgGraph

Source§

fn upsert_node(&self, node: &GraphNode) -> Result<()>

Insert or replace a node.
Source§

fn read_node(&self, id: &str) -> Result<Option<GraphNode>>

Read a single node by ID (None if absent).
Source§

fn delete_node(&self, id: &str) -> Result<bool>

Delete a node by ID. Returns true if a row was removed.
Source§

fn search_nodes(&self, query: &str, limit: usize) -> Result<Vec<GraphNode>>

FTS5 full-text search, ranked by importance DESC.
Source§

fn query_nodes( &self, tag: Option<&str>, node_type: Option<&str>, project: Option<&str>, limit: usize, ) -> Result<Vec<GraphNode>>

Dynamic filter by tag / node_type / project.
Source§

fn smart_recall( &self, project: Option<&str>, hint: Option<&str>, limit: usize, ) -> Result<Vec<ScoredNode>>

Composite recall — rank nodes by recency, importance, access, FTS, and graph boost. The canonical high-level read path for “what’s relevant”.
Source§

fn related_nodes(&self, start_id: &str, depth: usize) -> Result<Vec<String>>

BFS-traverse up to depth hops from start_id, returning related node IDs (excluding the start).
Source§

fn append_edge(&self, edge: &GraphEdge) -> Result<()>

Append an edge (duplicates by edge ID are ignored).
Source§

fn edges_for_node(&self, node_id: &str) -> Result<Vec<GraphEdge>>

Read edges where the given node is source or target.
Source§

fn delete_edge(&self, id: &str) -> Result<bool>

Delete an edge by ID. Returns true if a row was removed.
Source§

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

Remove every edge connected to a node.
Source§

fn current_version(&self) -> Result<u32>

Recorded schema version for this backend.
Source§

fn migrate(&self) -> Result<u32>

Apply pending migrations up to the backend’s latest schema version. Returns the resulting version.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more