pub struct GraphHandle { /* private fields */ }Implementations§
Source§impl GraphHandle
impl GraphHandle
pub fn new( path: &Path, durability: Durability, tuning: SqliteTuning, _lru_cache_size: NonZeroUsize, read_pool_size: usize, ) -> Result<Self>
pub fn get_entity(&self, name: &str) -> Result<Option<Entity>>
pub fn create_entities(&self, entities: &[EntityInput]) -> Result<Vec<Entity>>
pub fn upsert_entities(&self, entities: &[EntityInput]) -> Result<Vec<Entity>>
pub fn delete_entities(&self, names: &[String]) -> Result<()>
pub fn create_relations( &self, relations: &[RelationInput], ) -> Result<Vec<Relation>>
pub fn delete_relations(&self, relations: &[Relation]) -> Result<()>
pub fn add_relation_observations( &self, from: &str, to: &str, relation_type: &str, contents: &[ObservationInput], ) -> Result<Vec<Observation>>
pub fn delete_relation_observations( &self, from: &str, to: &str, relation_type: &str, observations: &[ObservationInput], ) -> Result<()>
pub fn set_attributes(&self, targets: &[AttributeSet]) -> Result<()>
pub fn delete_attributes(&self, targets: &[AttributeDelete]) -> Result<()>
pub fn add_observations( &self, entity_name: &str, contents: &[ObservationInput], ) -> Result<Vec<Observation>>
pub fn delete_observations( &self, entity_name: &str, observations: &[ObservationInput], ) -> Result<()>
pub fn merge_entities(&self, source: &str, target: &str) -> Result<Entity>
pub fn rename_entity(&self, old_name: &str, new_name: &str) -> Result<Entity>
Sourcepub fn code_purge_file(&self, rel_path: &str) -> Result<usize>
pub fn code_purge_file(&self, rel_path: &str) -> Result<usize>
Delete a code file and all its defined symbols in the same transaction.
pub fn search_nodes_filtered( &self, query: &str, filter_type: Option<&str>, offset: usize, limit: usize, ) -> Vec<Entity>
Sourcepub fn search_nodes_lite_json(
&self,
query: &str,
filter_type: Option<&str>,
offset: usize,
limit: usize,
) -> (String, usize, bool)
pub fn search_nodes_lite_json( &self, query: &str, filter_type: Option<&str>, offset: usize, limit: usize, ) -> (String, usize, bool)
The viewer’s search payload: a JSON array of {name, entityType, obsCount}
(no observation bodies — see [batch_entity_lite_by_ids]), in the same
order and with the same post-filter offset semantics as
Self::search_nodes_filtered. Returns (entities_json, returned, has_more); has_more is detected by fetching one extra match past the
page. Builds the JSON directly to avoid a Vec<Entity> round-trip.
pub fn read_graph_filtered( &self, filter_type: Option<&str>, offset: usize, limit: usize, ) -> Result<String>
Sourcepub fn read_graph_filtered_lite(
&self,
filter_type: Option<&str>,
offset: usize,
limit: usize,
) -> Result<(String, usize)>
pub fn read_graph_filtered_lite( &self, filter_type: Option<&str>, offset: usize, limit: usize, ) -> Result<(String, usize)>
Observation-free page for the browser viewer: entities carry obsCount
(the denormalised count) instead of the observation bodies, which the
canvas never renders in bulk — the inspector lazy-loads them for the one
selected node via GET /ui/node. Returns (json, returned) so the caller
can build the pagination cursor without re-parsing the payload.
pub fn open_nodes(&self, names: &[String]) -> String
pub fn entities_exist(&self, names: &[String]) -> Result<Vec<bool>>
pub fn degree(&self, name: &str, direction: Direction) -> Result<usize>
pub fn get_entity_count(&self) -> Result<usize>
pub fn get_relation_count(&self) -> Result<usize>
pub fn search_relations( &self, from: Option<&str>, to: Option<&str>, rtype: Option<&str>, query: Option<&str>, limit: Option<usize>, ) -> Result<Vec<RelationDetail>>
pub fn find_path(&self, from: &str, to: &str) -> Result<Option<Vec<String>>>
pub fn compact(&self) -> Result<()>
pub fn neighbors( &self, name: &str, direction: Direction, rtype: Option<&str>, depth: u32, ) -> Result<String>
pub fn extract_subgraph(&self, names: &[String], depth: u32) -> Result<String>
pub fn describe_entity(&self, name: &str) -> Result<EntityDescription>
pub fn entity_type_counts(&self) -> Vec<(String, usize)>
Sourcepub fn entity_type_catalog(&self) -> Vec<(String, usize, Option<String>)>
pub fn entity_type_catalog(&self) -> Vec<(String, usize, Option<String>)>
(name, count, desc) for every registered entity type: one with
members, or one whose description registers it before first use.
Sourcepub fn ui_meta(&self) -> (Vec<(String, usize)>, usize, usize)
pub fn ui_meta(&self) -> (Vec<(String, usize)>, usize, usize)
The viewer’s shared page metadata — entity-type legend and the graph-wide
entity/relation totals — gathered on a single reader connection. The
/ui/graph and /ui/search handlers used to take three or four separate
reader-pool acquisitions per request (entity_type_counts +
get_entity_count + get_relation_count); folding them into one lock
acquisition cuts pool churn and shortens the reader hold, which is what
bounds concurrent read throughput.
pub fn relation_type_counts(&self) -> Vec<(String, usize)>
Sourcepub fn relation_type_catalog(&self) -> Vec<(String, usize, Option<String>)>
pub fn relation_type_catalog(&self) -> Vec<(String, usize, Option<String>)>
(name, count, desc) for every registered relation type: one with
members, or one whose description registers it before first use.
Sourcepub fn set_type_description(
&self,
kind: i64,
name: &str,
description: Option<&str>,
) -> Result<()>
pub fn set_type_description( &self, kind: i64, name: &str, description: Option<&str>, ) -> Result<()>
Set or clear the description of one entity type (kind 0) or relation
type (kind 1) by exact name. The type row is created when it does
not exist yet — a description can thus register a type before its
first member (count stays 0). None clears the stored description.
This is registry metadata, not a graph mutation: no change event is
emitted and the taxonomy index revision is untouched.
Sourcepub fn entity_type_exists(&self, name: &str) -> bool
pub fn entity_type_exists(&self, name: &str) -> bool
Whether an entity type with the given name exists. Read-only: a missing type stays absent and no row is inserted.
Sourcepub fn relation_type_exists(&self, name: &str) -> bool
pub fn relation_type_exists(&self, name: &str) -> bool
Whether a relation type with the given name exists. Read-only: a missing type stays absent and no row is inserted.
pub fn batch_get_entities(&self, names: &[String]) -> Vec<Option<Entity>>
pub fn find_all_paths( &self, from: &str, to: &str, max_depth: usize, max_paths: usize, ) -> Result<Vec<Vec<String>>>
Sourcepub fn export(&self, _format: &str, max_rows: i64) -> Result<String>
pub fn export(&self, _format: &str, max_rows: i64) -> Result<String>
Export the whole graph as a JSON string. max_rows caps both the entity
and relation arrays so a pathologically large graph cannot be coerced
into an unbounded in-memory string (DoS guard); callers pass a generous
constant. A negative value means “no limit”.
pub fn wipe(&self) -> Result<()>
Sourcepub fn run_maintenance(&self) -> Result<()>
pub fn run_maintenance(&self) -> Result<()>
Periodic database maintenance: WAL checkpoint, query planner analysis, and FTS index optimization. Call from a background timer.
Sourcepub fn checkpoint_passive(&self) -> Result<()>
pub fn checkpoint_passive(&self) -> Result<()>
Run a non-blocking wal_checkpoint(PASSIVE) to fsync committed WAL frames
without stalling readers or writers. Call from a short-interval timer to
bound the durability window in async mode.