Struct tis_100::io::IoBus [] [src]

pub struct IoBus { /* fields omitted */ }

An IoBus is used to pass messages between nodes. Nodes are represented by usize indices. Nodes must first be connected before they can pass messages. Nodes can be connected using either half-duplex or full-duplex channels.

Once nodes are connected, they can pass messages through the IoBus using an IoBusView. An IoBusView ensures that a node can only read or write the ports that it is connected to. All writes are buffered. In order for a node to read a value that another node has sent it, the writes must be committed.

Examples

use tis_100::core::Port::*;
use tis_100::io::IoBus;

let mut bus = IoBus::new();

// In this example, 1 is right from 0, and 0 is left from 1.
bus.connect_full(0, 1, RIGHT);
assert!(bus.is_connected(0, 1, RIGHT));
assert!(bus.is_connected(1, 0, LEFT));
use tis_100::core::Port::*;
use tis_100::io::IoBus;

let mut bus = IoBus::new();
bus.connect_half(0, 1, RIGHT);

{
    let mut view = bus.view(0);
    view.write(RIGHT, 42);
}

bus.commit();

{
    let mut view = bus.view(1);
    assert_eq!(view.read(LEFT), Some(42));
}

Methods

impl IoBus
[src]

Construct a new, empty IoBus.

Create a one-way connection from one node to another in the given direction.

Create a two-way connection from one node to another in the given direction. The opposite direction will be used when connecting the second half.

Determine if two nodes are connected in a certain direction.

Returns a view of the IoBus for the given node.

Commits all outstanding writes and clears the write buffer.

Trait Implementations

impl Debug for IoBus
[src]

Formats the value using the given formatter.