pub struct Graph { /* private fields */ }Expand description
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn with_capacity(compile_cap: usize, resolution_cap: usize) -> Self
pub fn with_capacity(compile_cap: usize, resolution_cap: usize) -> Self
Create a graph backed by a VM with custom capacity hints.
compile_cap — compile-cache slots; resolution_cap — resolution-cache slots.
Sourcepub fn add_node<S: Into<String>>(&mut self, name: S, value: Value) -> &mut Self
pub fn add_node<S: Into<String>>(&mut self, name: S, value: Value) -> &mut Self
Add (or replace) a named node. Returns &mut self for chaining.
Sourcepub fn get_node(&self, name: &str) -> Option<&Value>
pub fn get_node(&self, name: &str) -> Option<&Value>
Return a reference to a node value, if it exists.
Sourcepub fn remove_node(&mut self, name: &str) -> Option<Value>
pub fn remove_node(&mut self, name: &str) -> Option<Value>
Remove a node, returning its value if it existed.
Sourcepub fn node_names(&self) -> impl Iterator<Item = &str>
pub fn node_names(&self) -> impl Iterator<Item = &str>
Return an iterator over node names.
Sourcepub fn query(&mut self, expr: &str) -> Result<Value, GraphError>
pub fn query(&mut self, expr: &str) -> Result<Value, GraphError>
Evaluate a v2 expression against the virtual root — a JSON object
{ "node_name": value, ... } containing all nodes.
Navigate into a node via $.node_name....
Sourcepub fn query_node(
&mut self,
node: &str,
expr: &str,
) -> Result<Value, GraphError>
pub fn query_node( &mut self, node: &str, expr: &str, ) -> Result<Value, GraphError>
Evaluate a v2 expression against a single named node directly.
Sourcepub fn register_method(
&mut self,
name: impl Into<String>,
method: impl Method + 'static,
)
pub fn register_method( &mut self, name: impl Into<String>, method: impl Method + 'static, )
Register a custom method callable from query expressions.
Sourcepub fn virtual_root(&self) -> Value
pub fn virtual_root(&self) -> Value
Build the virtual root object containing all nodes as top-level fields.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl !RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl !UnwindSafe for Graph
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