Skip to main content

GraphInstruction

Struct GraphInstruction 

Source
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

ActionSubjectObjectKey Params
create_modelroot_aliasgraphid (optional)name, ontology_class, ontology_id, slug
create_branchroot_aliasgraphid (optional)name, ontology_class, ontology_id, slug
add_nodeparent_aliasnew_aliasdatatype, name, ontology_class, cardinality, parent_property
add_edgedomain_aliasrange_aliasontology_property
add_nodegroupnode_alias(unused)cardinality
add_cardnodegroup_idcard_namecomponent_id
add_widgetnode_alias(unused)widget_id
add_subgraphtarget_alias(unused)subgraph (JSON), ontology_property, alias_suffix
update_subgraphtarget_alias(unused)subgraph (JSON), ontology_property, alias_suffix, remove_orphaned
concept_change_collectionnode_aliascollection_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: String

The action to perform

§subject: String

The subject (parent/source entity alias)

§object: String

The object (child/target entity alias or name)

§params: HashMap<String, Value>

Additional parameters

Implementations§

Source§

impl GraphInstruction

Source

pub fn new(action: &str, subject: &str, object: &str) -> Self

Create a new instruction

Source

pub fn with_param(self, key: &str, value: Value) -> Self

Add a parameter

Source

pub fn with_str(self, key: &str, value: &str) -> Self

Add a string parameter

Source

pub fn to_mutation(&self) -> Result<GraphMutation, MutationError>

Convert this instruction to a GraphMutation

Source

pub fn is_create_action(&self) -> bool

Check if this instruction creates or loads a graph

Source

pub fn conformance(&self) -> MutationConformance

Get the conformance level for this instruction action

Source

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 graph
  • object: 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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphInstruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GraphInstruction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for GraphInstruction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.