pub trait GraphReader: Send + Sync {
// Required methods
fn get_node(&self, id: NodeId) -> Result<Option<Node>>;
fn get_edge(&self, id: EdgeId) -> Result<Option<Edge>>;
fn all_node_ids(&self) -> Result<Vec<NodeId>>;
fn nodes_by_label(&self, label: &str) -> Result<Vec<NodeId>>;
fn nodes_by_property(
&self,
label: &str,
property: &str,
value: &Property,
) -> Result<Vec<NodeId>>;
fn outgoing(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>;
fn incoming(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>;
// Provided methods
fn list_property_indexes(&self) -> Result<Vec<(String, String)>> { ... }
fn list_property_constraints(&self) -> Result<Vec<PropertyConstraintSpec>> { ... }
}Expand description
Read-side counterpart to crate::GraphWriter. Gives the executor a
uniform view of the graph regardless of whether the data behind it lives
entirely in a local storage engine (single-node or full-replica Raft
mode) or is sharded across cluster peers (routing mode, where a
partitioned reader fans out point reads to owners and scatter-gathers
bulk scans).
Methods are sync because the executor’s iterator model is sync. Async-
backed implementations (e.g. a remote reader that talks gRPC) bridge via
Handle::block_on; callers must run the executor inside spawn_blocking
so they don’t stall the tokio runtime.
Required Methods§
fn get_node(&self, id: NodeId) -> Result<Option<Node>>
fn get_edge(&self, id: EdgeId) -> Result<Option<Edge>>
fn all_node_ids(&self) -> Result<Vec<NodeId>>
fn nodes_by_label(&self, label: &str) -> Result<Vec<NodeId>>
Sourcefn nodes_by_property(
&self,
label: &str,
property: &str,
value: &Property,
) -> Result<Vec<NodeId>>
fn nodes_by_property( &self, label: &str, property: &str, value: &Property, ) -> Result<Vec<NodeId>>
Equality lookup via a property index. Callers (planner) must
have verified the (label, property) index exists before
emitting this call — fallback implementations are free to do a
label-scan-and-filter for impls that don’t maintain their own
property index, but the storage-backed reader treats a call on
a non-existent index as an empty result since no entries are
maintained.
fn outgoing(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>
fn incoming(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>
Provided Methods§
Sourcefn list_property_indexes(&self) -> Result<Vec<(String, String)>>
fn list_property_indexes(&self) -> Result<Vec<(String, String)>>
Snapshot the (label, property) pairs of every property
index visible through this reader. Used by SHOW INDEXES.
Default impl returns empty — the storage-backed reader
overrides via the blanket impl, and partitioned/overlay
readers delegate to their bases.
Sourcefn list_property_constraints(&self) -> Result<Vec<PropertyConstraintSpec>>
fn list_property_constraints(&self) -> Result<Vec<PropertyConstraintSpec>>
Snapshot every registered constraint visible through this
reader, for SHOW CONSTRAINTS and db.constraints(). Default
impl returns empty; storage-backed readers override.
Implementors§
impl GraphReader for StorageReaderAdapter<'_>
impl<T: StorageEngine> GraphReader for T
Blanket impl: any sized type that implements StorageEngine
is automatically a GraphReader. Covers the concrete
meshdb_storage::RocksDbStorageEngine — a &RocksDbStorageEngine
coerces to &dyn GraphReader via this blanket.
Not covered: dyn StorageEngine itself. Rust does not transitively
coerce &dyn StorageEngine to &dyn GraphReader because trait
objects of unrelated traits carry different vtables and there’s no
supertrait relationship connecting them. Call sites that hold a
&dyn StorageEngine should use StorageReaderAdapter to wrap it
as a GraphReader.