pub trait NodeTemplateTrait: Clone {
type NodeData;
type DataType;
type ValueType;
type UserState;
type CategoryType;
// Required methods
fn node_finder_label(
&self,
user_state: &mut Self::UserState,
) -> Cow<'_, str>;
fn node_graph_label(&self, user_state: &mut Self::UserState) -> String;
fn user_data(&self, user_state: &mut Self::UserState) -> Self::NodeData;
fn build_node(
&self,
graph: &mut Graph<Self::NodeData, Self::DataType, Self::ValueType>,
user_state: &mut Self::UserState,
node_id: NodeId,
);
// Provided method
fn node_finder_categories(
&self,
_user_state: &mut Self::UserState,
) -> Vec<Self::CategoryType> { ... }
}Expand description
This trait must be implemented by the NodeTemplate generic parameter of
the GraphEditorState. It allows the customization of node templates. A
node template is what describes what kinds of nodes can be added to the
graph, what is their name, and what are their input / output parameters.
Required Associated Types§
Sourcetype CategoryType
type CategoryType
Must be a type that implements the CategoryTrait trait.
&'static str is a good default if you intend to simply type out
the categories of your node. Use () if you don’t need categories
at all.
Required Methods§
Sourcefn node_finder_label(&self, user_state: &mut Self::UserState) -> Cow<'_, str>
fn node_finder_label(&self, user_state: &mut Self::UserState) -> Cow<'_, str>
Returns a descriptive name for the node kind, used in the node finder.
The return type is CowDataTypeTrait::name for
more information
Sourcefn node_graph_label(&self, user_state: &mut Self::UserState) -> String
fn node_graph_label(&self, user_state: &mut Self::UserState) -> String
Returns a descriptive name for the node kind, used in the graph.
Sourcefn user_data(&self, user_state: &mut Self::UserState) -> Self::NodeData
fn user_data(&self, user_state: &mut Self::UserState) -> Self::NodeData
Returns the user data for this node kind.
Sourcefn build_node(
&self,
graph: &mut Graph<Self::NodeData, Self::DataType, Self::ValueType>,
user_state: &mut Self::UserState,
node_id: NodeId,
)
fn build_node( &self, graph: &mut Graph<Self::NodeData, Self::DataType, Self::ValueType>, user_state: &mut Self::UserState, node_id: NodeId, )
This function is run when this node kind gets added to the graph. The node will be empty by default, and this function can be used to fill its parameters.
Provided Methods§
Sourcefn node_finder_categories(
&self,
_user_state: &mut Self::UserState,
) -> Vec<Self::CategoryType>
fn node_finder_categories( &self, _user_state: &mut Self::UserState, ) -> Vec<Self::CategoryType>
Vec of categories to which the node belongs.
It’s often useful to organize similar nodes into categories, which will then be used by the node finder to show a more manageable UI, especially if the node template are numerous.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.