Struct Graph

Source
pub struct Graph<NodeData, DataType, ValueType> {
    pub nodes: SlotMap<NodeId, Node<NodeData>>,
    pub inputs: SlotMap<InputId, InputParam<DataType, ValueType>>,
    pub outputs: SlotMap<OutputId, OutputParam<DataType>>,
    pub connections: SecondaryMap<InputId, OutputId>,
}
Expand description

The graph, containing nodes, input parameters and output parameters. Because graphs are full of self-referential structures, this type uses the slotmap crate to represent all the inner references in the data.

Fields§

§nodes: SlotMap<NodeId, Node<NodeData>>

The Nodes of the graph

§inputs: SlotMap<InputId, InputParam<DataType, ValueType>>

The InputParams of the graph

§outputs: SlotMap<OutputId, OutputParam<DataType>>

The OutputParams of the graph

§connections: SecondaryMap<InputId, OutputId>

Implementations§

Source§

impl<NodeData, DataType, ValueType> Graph<NodeData, DataType, ValueType>
where DataType: PartialEq,

Source

pub fn new() -> Self

Source

pub fn add_node( &mut self, label: String, user_data: NodeData, f: impl FnOnce(&mut Graph<NodeData, DataType, ValueType>, NodeId), ) -> NodeId

Source

pub fn add_input_param( &mut self, node_id: NodeId, name: String, typ: DataType, value: ValueType, kind: InputParamKind, shown_inline: bool, ) -> InputId

Source

pub fn update_input_param( &mut self, input_id: InputId, name: Option<String>, typ: Option<DataType>, value: Option<ValueType>, kind: Option<InputParamKind>, shown_inline: Option<bool>, )

Source

pub fn remove_input_param(&mut self, param: InputId)

Source

pub fn add_output_param( &mut self, node_id: NodeId, name: String, typ: DataType, ) -> OutputId

Source

pub fn update_output_param( &mut self, output_id: OutputId, name: Option<String>, typ: Option<DataType>, )

Source

pub fn remove_output_param(&mut self, param: OutputId)

Source

pub fn ensure_connection_types(&mut self, param_id: AnyParameterId)

Deletes mistyped connection made with param_id

This is only needed connection param type is changed with means other than Graph::update_input_param.

Source

pub fn remove_node( &mut self, node_id: NodeId, ) -> (Node<NodeData>, Vec<(InputId, OutputId)>)

Removes a node from the graph with given node_id. This also removes any incoming or outgoing connections from that node

This function returns the list of connections that has been removed after deleting this node as input-output pairs. Note that one of the two ids in the pair (the one on node_id’s end) will be invalid after calling this function.

Source

pub fn remove_connection(&mut self, input_id: InputId) -> Option<OutputId>

Source

pub fn iter_nodes(&self) -> impl Iterator<Item = NodeId> + '_

Source

pub fn add_connection(&mut self, output: OutputId, input: InputId)

Source

pub fn iter_connections(&self) -> impl Iterator<Item = (InputId, OutputId)> + '_

Source

pub fn connection(&self, input: InputId) -> Option<OutputId>

Source

pub fn any_param_type( &self, param: AnyParameterId, ) -> Result<&DataType, EguiGraphError>

Source

pub fn try_get_input( &self, input: InputId, ) -> Option<&InputParam<DataType, ValueType>>

Source

pub fn get_input(&self, input: InputId) -> &InputParam<DataType, ValueType>

Source

pub fn try_get_output(&self, output: OutputId) -> Option<&OutputParam<DataType>>

Source

pub fn get_output(&self, output: OutputId) -> &OutputParam<DataType>

Trait Implementations§

Source§

impl<NodeData: Clone, DataType: Clone, ValueType: Clone> Clone for Graph<NodeData, DataType, ValueType>

Source§

fn clone(&self) -> Graph<NodeData, DataType, ValueType>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<NodeData: Debug, DataType: Debug, ValueType: Debug> Debug for Graph<NodeData, DataType, ValueType>

Source§

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

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

impl<NodeData, DataType, ValueType> Default for Graph<NodeData, DataType, ValueType>
where DataType: PartialEq,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A, B, C> Index<InputId> for Graph<A, B, C>

Source§

type Output = InputParam<B, C>

The returned type after indexing.
Source§

fn index(&self, index: InputId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<A, B, C> Index<NodeId> for Graph<A, B, C>

Source§

type Output = Node<A>

The returned type after indexing.
Source§

fn index(&self, index: NodeId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<A, B, C> Index<OutputId> for Graph<A, B, C>

Source§

type Output = OutputParam<B>

The returned type after indexing.
Source§

fn index(&self, index: OutputId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<A, B, C> IndexMut<InputId> for Graph<A, B, C>

Source§

fn index_mut(&mut self, index: InputId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<A, B, C> IndexMut<NodeId> for Graph<A, B, C>

Source§

fn index_mut(&mut self, index: NodeId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<A, B, C> IndexMut<OutputId> for Graph<A, B, C>

Source§

fn index_mut(&mut self, index: OutputId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<NodeData, DataType, ValueType> Freeze for Graph<NodeData, DataType, ValueType>

§

impl<NodeData, DataType, ValueType> RefUnwindSafe for Graph<NodeData, DataType, ValueType>
where NodeData: RefUnwindSafe, DataType: RefUnwindSafe, ValueType: RefUnwindSafe,

§

impl<NodeData, DataType, ValueType> Send for Graph<NodeData, DataType, ValueType>
where NodeData: Send, DataType: Send, ValueType: Send,

§

impl<NodeData, DataType, ValueType> Sync for Graph<NodeData, DataType, ValueType>
where NodeData: Sync, DataType: Sync, ValueType: Sync,

§

impl<NodeData, DataType, ValueType> Unpin for Graph<NodeData, DataType, ValueType>
where NodeData: Unpin, DataType: Unpin, ValueType: Unpin,

§

impl<NodeData, DataType, ValueType> UnwindSafe for Graph<NodeData, DataType, ValueType>
where NodeData: UnwindSafe, DataType: UnwindSafe, ValueType: UnwindSafe,

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<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> 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> 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.
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,