Aggregator

Struct Aggregator 

Source
pub struct Aggregator<I: IntoIoSignature, O: IntoIoSignature> { /* private fields */ }
Expand description

The Aggregator is put “around” some implementation of Node. It handles waiting for data, edge assignment as well as using default data provided by the nodes default() function if no edge is supplied for some port.

Implementations§

Source§

impl<I, O> Aggregator<I, O>

Source

pub fn from_node<N>(node: N) -> Self
where N: Node<InSig = I, OutSig = O> + Send + 'static,

Creates this aggregator from some Node implementing object. Takes ownership of that node. If that is not desired, use the from_arc() function.

Examples found in repository?
examples/math.rs (line 54)
51fn main(){
52    let ex = Executor::new();
53    
54    let add_node1 = Arc::new(Mutex::new(Aggregator::from_node(Add)));
55    let add_node2 = Arc::new(Mutex::new(Aggregator::from_node(Add)));
56    let printer = Arc::new(Mutex::new(Aggregator::from_node(Printer)));
57    
58    Edge::connect(add_node1.clone(), 0, add_node2.clone(), 1).expect("Failed to connect edge");
59    Edge::connect(add_node2.clone(), 0, printer.clone(), 0).expect("Failed to connect edge");
60    
61    //Should execute since the other edge is set by the default value
62    add_node1.lock().unwrap().set_in_from_edge(ex.clone(), 1, Box::new(2.0 as f32)).expect("Failed to set input");
63
64    std::thread::sleep(std::time::Duration::from_secs(1));
65}
Source

pub fn from_arc<N>(node: Arc<Mutex<N>>) -> Self
where N: Node<InSig = I, OutSig = O> + Send + 'static,

Trait Implementations§

Source§

impl<I, O> AbstAggregator for Aggregator<I, O>

Source§

fn set_in_edge(&mut self, edge: Edge) -> Result<(), DErr>

Source§

fn set_out_edge(&mut self, edge: Edge) -> Result<(), DErr>

Source§

fn notify_in_remove(&mut self, port_idx: usize) -> Result<Edge, DErr>

Removes the in edge at port_idx. Returns the removed edge, or why this wasn’t possible.
Source§

fn notify_out_remove(&mut self, port_idx: usize) -> Result<Edge, DErr>

Removes the out edge at port_idx. Returns the removed edge, or why this wasn’t possible.
Source§

fn set_in_from_edge( &mut self, executor: Arc<Executor>, idx: usize, value: Box<dyn Any>, ) -> Result<(), DErr>

Source§

fn set_default_value( &mut self, idx: usize, value: Box<dyn Any>, ) -> Result<(), DErr>

Source§

fn in_type_id(&self, in_port_idx: usize) -> Option<TypeId>

Source§

fn out_type_id(&self, out_port_idx: usize) -> Option<TypeId>

Source§

fn remove_in_edge(&mut self, port_idx: usize) -> Result<(), DErr>

Removes some edge. Should also notify the partner on this edge. Should do nothing, if the node has not edge set at the edge’s end_idx.
Source§

fn remove_out_edge(&mut self, port_idx: usize) -> Result<(), DErr>

See remove_in_edge, but in reverse.
Source§

impl<O> Executable for Aggregator<(), O>
where O: IntoIoSignature,

Source§

fn execute(&mut self, executor: Arc<Executor>) -> Result<(), DErr>

Auto Trait Implementations§

§

impl<I, O> Freeze for Aggregator<I, O>

§

impl<I, O> RefUnwindSafe for Aggregator<I, O>

§

impl<I, O> Send for Aggregator<I, O>

§

impl<I, O> Sync for Aggregator<I, O>

§

impl<I, O> Unpin for Aggregator<I, O>

§

impl<I, O> UnwindSafe for Aggregator<I, O>

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, 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.