Join

Trait Join 

Source
pub trait Join: Sized {
    // Required method
    fn join(&mut self, others: Box<[Self]>);
}
Expand description

The Join trait is used for merging multiple instances of a context into one.

Join is typically used after parallel execution, where several contexts (or partial results) must be combined back into a single instance.

This trait complements Fork, enabling a fork-join lifecycle for contexts.

§Examples

use node_flow::context::Join;

struct Sum(usize);

impl Join for Sum {
    fn join(&mut self, others: Box<[Self]>) {
        for other in others {
            self.0 += other.0;
        }
    }
}

let mut total = Sum(5);
total.join(Box::new([Sum(2), Sum(3)]));
assert_eq!(total.0, 10);

Required Methods§

Source

fn join(&mut self, others: Box<[Self]>)

Joins the state of multiple others into this instance.

Implementors define how merging should occur. For example it could be summation, set unions or aggregation.

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 Join for LocalStorageImpl

Available on crate feature local_storage_impl only.
Source§

impl Join for SharedStorageImpl

Available on crate feature shared_storage_impl only.