pub struct GraphHandle<'a> { /* private fields */ }Expand description
A fluent knowledge-graph traversal, created by Laser::graph. Set a start
(start_ids/start_match/start_nearest), add hops (out/incoming), pick
what to return, and finish with .fetch().await. Gated on the graph
feature: a traversal rides the managed binary transport.
Implementations§
Source§impl GraphHandle<'_>
impl GraphHandle<'_>
Sourcepub fn in_session(self, session: SessionRef) -> Self
pub fn in_session(self, session: SessionRef) -> Self
Link every upsert to session, so the deployment records which session
wrote each element.
Sourcepub fn produced_by(self, producer: ProducerInfo) -> Self
pub fn produced_by(self, producer: ProducerInfo) -> Self
Stamp producer on every upserted element that has none.
Sourcepub fn sourced_from(self, source: SourceRef) -> Self
pub fn sourced_from(self, source: SourceRef) -> Self
Stamp source on every upserted element that has none.
Sourcepub fn conversation(self, conversation: ConversationId) -> Self
pub fn conversation(self, conversation: ConversationId) -> Self
Narrow the traversal to elements a single conversation asserted (the
conversation lens): only nodes and edges whose source records that
conversation are traversed and returned. Applies to both fetch and
neighbors. Reads the whole graph when unset.
Sourcepub fn start_match(self, filter: Filter) -> Self
pub fn start_match(self, filter: Filter) -> Self
Start from the nodes matching a predicate.
Sourcepub fn start_nearest(self, embedding: Vec<f32>, k: usize) -> Self
pub fn start_nearest(self, embedding: Vec<f32>, k: usize) -> Self
Start from the nodes nearest an embedding (vector-seeded traversal).
Sourcepub fn out(self, edge_type: impl Into<String>) -> Self
pub fn out(self, edge_type: impl Into<String>) -> Self
Follow outgoing edges of edge_type one hop.
Sourcepub fn incoming(self, edge_type: impl Into<String>) -> Self
pub fn incoming(self, edge_type: impl Into<String>) -> Self
Follow incoming edges of edge_type one hop.
Sourcepub fn both(self, edge_type: impl Into<String>) -> Self
pub fn both(self, edge_type: impl Into<String>) -> Self
Follow edges of edge_type one hop in both directions.
Sourcepub fn return_edges(self) -> Self
pub fn return_edges(self) -> Self
Return the traversed edges instead of the reachable nodes.
Sourcepub fn return_triplets(self) -> Self
pub fn return_triplets(self) -> Self
Return the traversed edges as (source, type, destination) triplets
instead of the reachable nodes.
Sourcepub fn return_paths(self) -> Self
pub fn return_paths(self) -> Self
Return whole paths (node and edge id sequences) instead of nodes.
Sourcepub fn as_of(self, micros: u64) -> Self
pub fn as_of(self, micros: u64) -> Self
Read the graph as of micros (valid-time, epoch micros): only edges whose
valid-time window contains that instant are traversed. Applies to both
fetch and neighbors.
Sourcepub async fn fetch(self) -> Result<GraphResult, LaserError>
pub async fn fetch(self) -> Result<GraphResult, LaserError>
Run the traversal. Requires managed_graph. Otherwise returns
LaserError::Unsupported.
Sourcepub async fn neighbors(
self,
node: NodeId,
dir: EdgeDir,
edge_type: Option<String>,
depth: u32,
) -> Result<GraphResult, LaserError>
pub async fn neighbors( self, node: NodeId, dir: EdgeDir, edge_type: Option<String>, depth: u32, ) -> Result<GraphResult, LaserError>
Read a node’s neighbors: the nodes reachable in dir over edge_type (or
any type when None), following the same hop depth times. The cheap,
common traversal. Requires managed_graph. Otherwise returns
LaserError::Unsupported.
Sourcepub async fn link(
self,
from: impl Into<String>,
relation: impl Into<String>,
to: impl Into<String>,
) -> Result<(), LaserError>
pub async fn link( self, from: impl Into<String>, relation: impl Into<String>, to: impl Into<String>, ) -> Result<(), LaserError>
Relate two entities in one call: link("operator:42", "opened", "ticket:7") upserts both content-addressed entity nodes and the typed
edge between them. Sugar over upsert, so re-linking
the same triple converges on the same nodes and edge. The entity ids
double as their labels’ values (kind:value strings work well).
Sourcepub async fn relink(
self,
from: impl Into<String>,
relation: impl Into<String>,
to: impl Into<String>,
) -> Result<usize, LaserError>
pub async fn relink( self, from: impl Into<String>, relation: impl Into<String>, to: impl Into<String>, ) -> Result<usize, LaserError>
Assert the latest value of a single-valued relationship: close every
live relation edge from from that points at a DIFFERENT target
(valid_to now, the bitemporal supersede), then link from to to.
The deterministic fact-invalidation mechanics (same subject, same
predicate, new object supersedes the old), returning how many edges
were closed. Contradiction detection beyond same-subject-same-predicate
is the caller’s policy, and recording an improve feedback item that
links superseded to superseding is the caller’s memory concern.
Sourcepub async fn unlink(
self,
from: impl Into<String>,
relation: impl Into<String>,
to: impl Into<String>,
) -> Result<(), LaserError>
pub async fn unlink( self, from: impl Into<String>, relation: impl Into<String>, to: impl Into<String>, ) -> Result<(), LaserError>
Close the relationship link opened: rewrite the edge with valid_to
now, so the fact is superseded without being destroyed (a bitemporal
close). The nodes stay.
Sourcepub async fn upsert(
self,
nodes: Vec<GraphNode>,
edges: Vec<GraphEdge>,
) -> Result<(), LaserError>
pub async fn upsert( self, nodes: Vec<GraphNode>, edges: Vec<GraphEdge>, ) -> Result<(), LaserError>
Write nodes and edges into the graph: the projector path, surfaced for
callers that build the graph directly rather than through a graph
projection. Idempotent on content-addressed ids
(GraphNode::entity,
GraphEdge::relate), so re-applying
the same entities is a no-op. Requires managed_graph. Otherwise returns
LaserError::Unsupported.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for GraphHandle<'a>
impl<'a> !UnwindSafe for GraphHandle<'a>
impl<'a> Freeze for GraphHandle<'a>
impl<'a> Send for GraphHandle<'a>
impl<'a> Sync for GraphHandle<'a>
impl<'a> Unpin for GraphHandle<'a>
impl<'a> UnsafeUnpin for GraphHandle<'a>
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.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<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.