MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / remove_node

Method remove_node

crates/firewheel-graph/src/graph.rs:258–301  ·  view source on GitHub ↗

Remove the given node from the audio graph. This will automatically remove all edges from the graph that were connected to this node. On success, this returns a list of all edges that were removed from the graph as a result of removing this node. This will return an error if the ID is of the graph input or graph output node.

(
        &mut self,
        node_id: NodeID,
        is_restoring_graph_state: bool,
    )

Source from the content-addressed store, hash-verified

256 /// This will return an error if the ID is of the graph input or graph
257 /// output node.
258 pub fn remove_node(
259 &mut self,
260 node_id: NodeID,
261 is_restoring_graph_state: bool,
262 ) -> Result<SmallVec<[Edge; 4]>, RemoveNodeError> {
263 if node_id == self.graph_in_id {
264 return Err(RemoveNodeError::CannotRemoveGraphInNode);
265 }
266 if node_id == self.graph_out_id {
267 return Err(RemoveNodeError::CannotRemoveGraphOutNode);
268 }
269
270 let mut removed_edges = SmallVec::new();
271
272 let Some(node_entry) = self.nodes.remove(node_id.0) else {
273 return Ok(removed_edges);
274 };
275
276 for port_idx in 0..node_entry.info.channel_config.num_inputs.get() {
277 removed_edges.append(&mut self.remove_edges_with_input_port(
278 node_id,
279 port_idx,
280 is_restoring_graph_state,
281 ));
282 }
283 for port_idx in 0..node_entry.info.channel_config.num_outputs.get() {
284 removed_edges.append(&mut self.remove_edges_with_output_port(
285 node_id,
286 port_idx,
287 is_restoring_graph_state,
288 ));
289 }
290
291 self.needs_compile = true;
292
293 if !is_restoring_graph_state && let Some(guard) = self.modify_guard_stack.last_mut() {
294 guard.removed_nodes.push(node_entry);
295 } else {
296 self.nodes_to_remove_from_schedule.push(node_id);
297 self.active_nodes_to_remove.insert(node_id, node_entry);
298 }
299
300 Ok(removed_edges)
301 }
302
303 /// Get information about a node in the graph.
304 pub fn node_info(&self, id: NodeID) -> Option<&NodeEntry> {

Callers 1

clap_drop_orderingFunction · 0.45

Calls 6

removeMethod · 0.80
getMethod · 0.45
pushMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected