Skip to main content

ProcessingGraph

Struct ProcessingGraph 

Source
pub struct ProcessingGraph {
    pub nodes: Vec<GraphNode>,
    pub edges: Vec<GraphEdge>,
    pub is_locked: bool,
}
Expand description

A directed acyclic graph of media processing nodes.

Fields§

§nodes: Vec<GraphNode>

All nodes in the graph.

§edges: Vec<GraphEdge>

All edges in the graph.

§is_locked: bool

When true the graph is considered executing and hot-swap is refused.

Implementations§

Source§

impl ProcessingGraph

Source

pub fn new() -> Self

Creates an empty processing graph.

Source

pub fn add_node(&mut self, node: GraphNode)

Adds node to the graph. Duplicate IDs are allowed but discouraged.

Source

pub fn remove_node(&mut self, id: u64) -> bool

Removes the node with id and all edges referencing it.

Returns true if a node was removed.

Source

pub fn connect( &mut self, from: u64, from_port: u32, to: u64, to_port: u32, ) -> bool

Adds an edge from (from, from_port) to (to, to_port).

Returns false if either node does not exist; true on success.

Source

pub fn disconnect(&mut self, from: u64, to: u64) -> bool

Removes all edges from node from to node to.

Returns true if at least one edge was removed.

Source

pub fn source_nodes(&self) -> Vec<&GraphNode>

Returns references to all nodes whose type has zero inputs (source nodes).

Source

pub fn sink_nodes(&self) -> Vec<&GraphNode>

Returns references to all nodes whose type has zero outputs (sink nodes).

Source

pub fn execution_order(&self) -> Vec<u64>

Returns node IDs in topological execution order (Kahn’s algorithm).

Nodes not reachable from any source, or that form cycles, are appended in arbitrary order at the end.

Source§

impl ProcessingGraph

Source

pub fn hot_swap_node( &mut self, node_id: u64, replacement: GraphNode, ) -> HotSwapResult

Replace the node identified by node_id with replacement.

All edges connected to node_id are preserved — only the node’s internal data (name, params, type) is swapped. The swap is refused if:

When HotSwapResult::Success is returned the replacement node’s id field is forced to node_id so that all edge references remain valid.

§Complexity

O(n) where n is the number of nodes (linear scan to locate the node slot). Edge preservation is trivially O(1) because edges reference node IDs, not positions; no edge data is modified.

Source

pub fn lock(&mut self)

Lock the graph to simulate an executing state (prevents hot-swap).

Call ProcessingGraph::unlock when execution completes.

Source

pub fn unlock(&mut self)

Unlock the graph after execution completes.

Source

pub fn is_locked(&self) -> bool

Returns true if the graph is currently locked (executing).

Trait Implementations§

Source§

impl Debug for ProcessingGraph

Source§

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

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

impl Default for ProcessingGraph

Source§

fn default() -> ProcessingGraph

Returns the “default value” for a type. 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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.