pub struct GraphInstruction {
pub action: String,
pub subject: String,
pub object: String,
pub params: HashMap<String, Value>,
}Expand description
A row-based instruction for graph building
This provides a triple-like DSL for building graphs:
action: The operation to perform (add_node, add_edge, etc.)subject: The source/parent entity (alias or ID)object: The target/new entity (alias, name, or ID)params: Additional parameters as key-value pairs
§Actions and their semantics
| Action | Subject | Object | Key Params |
|---|---|---|---|
create_model | root_alias | graphid (optional) | name, ontology_class, ontology_id, slug |
create_branch | root_alias | graphid (optional) | name, ontology_class, ontology_id, slug |
add_node | parent_alias | new_alias | datatype, name, ontology_class, cardinality, parent_property |
add_edge | domain_alias | range_alias | ontology_property |
add_nodegroup | node_alias | (unused) | cardinality |
add_card | nodegroup_id | card_name | component_id |
add_widget | node_alias | (unused) | widget_id |
add_subgraph | target_alias | (unused) | subgraph (JSON), ontology_property, alias_suffix |
update_subgraph | target_alias | (unused) | subgraph (JSON), ontology_property, alias_suffix, remove_orphaned |
concept_change_collection | node_alias | collection_id | (none) |
Note: create_model and create_branch must be the first instruction when using
build_graph_from_instructions(). They create a new graph rather than mutating one.
Fields§
§action: StringThe action to perform
subject: StringThe subject (parent/source entity alias)
object: StringThe object (child/target entity alias or name)
params: HashMap<String, Value>Additional parameters
Implementations§
Source§impl GraphInstruction
impl GraphInstruction
Sourcepub fn with_param(self, key: &str, value: Value) -> Self
pub fn with_param(self, key: &str, value: Value) -> Self
Add a parameter
Sourcepub fn to_mutation(&self) -> Result<GraphMutation, MutationError>
pub fn to_mutation(&self) -> Result<GraphMutation, MutationError>
Convert this instruction to a GraphMutation
Sourcepub fn is_create_action(&self) -> bool
pub fn is_create_action(&self) -> bool
Check if this instruction creates or loads a graph
Sourcepub fn conformance(&self) -> MutationConformance
pub fn conformance(&self) -> MutationConformance
Get the conformance level for this instruction action
Sourcepub fn to_skeleton_graph(&self) -> Result<StaticGraph, MutationError>
pub fn to_skeleton_graph(&self) -> Result<StaticGraph, MutationError>
Convert a create_model or create_branch instruction to a skeleton graph
§Arguments
subject: root alias for the graphobject: graphid (if empty, generated from name)params.name: graph name (defaults to subject if not provided)params.ontology_class: optional ontology class for root node
§Returns
A new skeleton StaticGraph, or error if not a create action
Trait Implementations§
Source§impl Clone for GraphInstruction
impl Clone for GraphInstruction
Source§fn clone(&self) -> GraphInstruction
fn clone(&self) -> GraphInstruction
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GraphInstruction
impl Debug for GraphInstruction
Source§impl<'de> Deserialize<'de> for GraphInstruction
impl<'de> Deserialize<'de> for GraphInstruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GraphInstruction
impl RefUnwindSafe for GraphInstruction
impl Send for GraphInstruction
impl Sync for GraphInstruction
impl Unpin for GraphInstruction
impl UnsafeUnpin for GraphInstruction
impl UnwindSafe for GraphInstruction
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