Trait NodeWrapper

Source
pub trait NodeWrapper: NodeClass {
    type Payload: Copy + Default;
    type Consumer: Copy + Hash;
    type Producer: Copy + Hash;

    // Provided methods
    fn tick(&mut self) { ... }
    fn read<IntoP>(&self, producer: IntoP) -> Self::Payload
       where IntoP: Into<Self::Producer> { ... }
    fn write<IntoC>(&mut self, consumer: IntoC, _input: Self::Payload)
       where IntoC: Into<Self::Consumer> { ... }
}
Expand description

Wrapper around the internal representation of Node.

This type abstracts all the nodes registered by the user. Its main significance is that it is being returned from the graph when looking up nodes. Read the Node documentation to learn about its usage.

§Example

let node_index = graph.add_node(Generator(1));
let node_wrapper = graph.node(&node_index).unwrap();
let data = node_wrapper.read(GeneratorProducer);

Required Associated Types§

Provided Methods§

Source

fn tick(&mut self)

Source

fn read<IntoP>(&self, producer: IntoP) -> Self::Payload
where IntoP: Into<Self::Producer>,

Read data from the given producer.

§Panics

In case the given producer does not belong to this node type, this will panic.

Source

fn write<IntoC>(&mut self, consumer: IntoC, _input: Self::Payload)
where IntoC: Into<Self::Consumer>,

Write data into the given consumer.

§Panics

In case the given consumer does not belong to this node type, this will panic.

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§