pub fn validate_edge(&mut self, edge: &Edge) -> Result<(), RenderGraphError> {
        if self.has_edge(edge) {
            return Err(RenderGraphError::EdgeAlreadyExists(edge.clone()));
        }

        match *edge {
            Edge::SlotEdge {
                output_node,
                output_index,
                input_node,
                input_index,
            } => {
                let output_node_state = self.get_node_state(output_node)?;
                let input_node_state = self.get_node_state(input_node)?;

                let output_slot = output_node_state
                    .output_slots
                    .get_slot(output_index)
                    .ok_or(RenderGraphError::InvalidOutputNodeSlot(SlotLabel::Index(
                        output_index,
                    )))?;
                let input_slot = input_node_state.input_slots.get_slot(input_index).ok_or(
                    RenderGraphError::InvalidInputNodeSlot(SlotLabel::Index(input_index)),
                )?;

                if let Some(Edge::SlotEdge {
                    output_node: current_output_node,
                    ..
                }) = input_node_state.edges.input_edges.iter().find(|e| {
                    if let Edge::SlotEdge {
                        input_index: current_input_index,
                        ..
                    } = e
                    {
                        input_index == *current_input_index
                    } else {
                        false
                    }
                }) {
                    return Err(RenderGraphError::NodeInputSlotAlreadyOccupied {
                        node: input_node,
                        input_slot: input_index,
                        occupied_by_node: *current_output_node,
                    });
                }

                if output_slot.slot_type != input_slot.slot_type {
                    return Err(RenderGraphError::MismatchedNodeSlots {
                        output_node,
                        output_slot: output_index,
                        input_node,
                        input_slot: input_index,
                    });
                }
            }
            Edge::NodeEdge { .. } => { /* nothing to validate here */ }
        }

        Ok(())
    }
/// Verifies that the edge is not already existing and
/// checks that slot edges are connected correctly.
Verifies that the edge is not already existing and
checks that slot edges are connected correctly.
Verifies that the edge is not already existing and checks that slot edges are connected correctly .
pub fn validate_edge(&mut self, edge: &Edge) -> Result<(), RenderGraphError> {
        if self.has_edge(edge) {
            return Err(RenderGraphError::EdgeAlreadyExists(edge.clone()));
        }
        match *edge {
            Edge::SlotEdge {
                output_node,
                output_index,
                input_node,
                input_index,
            } => {
                let output_node_state = self.get_node_state(output_node)?;
                let input_node_state = self.get_node_state(input_node)?;
                let output_slot = output_node_state
                    .output_slots
                    .get_slot(output_index)
                    .ok_or(RenderGraphError::InvalidOutputNodeSlot(SlotLabel::Index(
                        output_index,
                    )))?;
                let input_slot = input_node_state.input_slots.get_slot(input_index).ok_or(
                    RenderGraphError::InvalidInputNodeSlot(SlotLabel::Index(input_index)),
                )?;
                if let Some(Edge::SlotEdge {
                    output_node: current_output_node,
                    ..
                }) = input_node_state.edges.input_edges.iter().find(|e| {
                    if let Edge::SlotEdge {
                        input_index: current_input_index,
                        ..
                    } = e
                    {
                        input_index == *current_input_index
                    } else {
                        false
                    }
                }) {
                    return Err(RenderGraphError::NodeInputSlotAlreadyOccupied {
                        node: input_node,
                        input_slot: input_index,
                        occupied_by_node: *current_output_node,
                    });
                }
                if output_slot.slot_type != input_slot.slot_type {
                    return Err(RenderGraphError::MismatchedNodeSlots {
                        output_node,
                        output_slot: output_index,
                        input_node,
                        input_slot: input_index,
                    });
                }
            }
            Edge::NodeEdge { .. } => { /* nothing to validate here */ }
        }
        Ok(())
    }
pub fn validate_edge ( & mut self , edge : & Edge ) -> Result < ( ) , RenderGraphError > { if self . has_edge ( edge ) { return Err ( RenderGraphError :: EdgeAlreadyExists ( edge . clone ( ) ) ) ; } match * edge { Edge :: SlotEdge { output_node , output_index , input_node , input_index , } => { let output_node_state = self . get_node_state ( output_node ) ? ; let input_node_state = self . get_node_state ( input_node ) ? ; let output_slot = output_node_state . output_slots . get_slot ( output_index ) . ok_or ( RenderGraphError :: InvalidOutputNodeSlot ( SlotLabel :: Index ( output_index , ) ) ) ? ; let input_slot = input_node_state . input_slots . get_slot ( input_index ) . ok_or ( RenderGraphError :: InvalidInputNodeSlot ( SlotLabel :: Index ( input_index ) ) , ) ? ; if let Some ( Edge :: SlotEdge { output_node : current_output_node , .. } ) = input_node_state . edges . input_edges . iter ( ) . find ( | e | { if let Edge :: SlotEdge { input_index : current_input_index , .. } = e { input_index == * current_input_index } else { false } } ) { return Err ( RenderGraphError :: NodeInputSlotAlreadyOccupied { node : input_node , input_slot : input_index , occupied_by_node : * current_output_node , } ) ; } if output_slot . slot_type != input_slot . slot_type { return Err ( RenderGraphError :: MismatchedNodeSlots { output_node , output_slot : output_index , input_node , input_slot : input_index , } ) ; } } Edge :: NodeEdge { .. } => { /* nothing to validate here */ } } Ok ( ( ) ) }
Verifies that the edge is not already existing and
checks that slot edges are connected correctly.
Verifies that the edge is not already existing and checks that slot edges are connected correctly .
&mut self
edge
&Edge
&mut self
edge
&Edge