Skip to main content

GraphExt

Trait GraphExt 

Source
pub trait GraphExt: DspNode + Sized {
    // Provided methods
    fn serial<B: DspNode>(self, other: B) -> Serial<Self, B> { ... }
    fn parallel<B: DspNode>(self, other: B) -> Parallel<Self, B> { ... }
    fn stack<B: DspNode>(self, other: B) -> Stack<Self, B> { ... }
}
Expand description

Extension trait that adds graph-composition methods to every DspNode.

Prefer these methods over the operator impls when chaining more than two nodes, since they avoid having to spell out type parameters:

use resonant_stream::{Chunk, DspNode, StreamError};
use resonant_stream::graph::GraphExt;

struct Noop;
impl DspNode for Noop {
    fn process(&mut self, input: Chunk) -> Result<Chunk, StreamError> { Ok(input) }
    fn reset(&mut self) {}
}

let _ = Noop.serial(Noop).serial(Noop); // (Noop >> Noop) >> Noop

Provided Methods§

Source

fn serial<B: DspNode>(self, other: B) -> Serial<Self, B>

Chain self into other serially: self’s output → other’s input.

Source

fn parallel<B: DspNode>(self, other: B) -> Parallel<Self, B>

Run self and other on the same input; sum their outputs.

Source

fn stack<B: DspNode>(self, other: B) -> Stack<Self, B>

Run self and other on the same input; concatenate their outputs.

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.

Implementors§

Source§

impl<T: DspNode + Sized> GraphExt for T