Struct rustfbp::ports::Ports [] [src]

pub struct Ports { /* fields omitted */ }

Represents all the ports of a component

It provides help to send and receive IP, and to create ports.

Methods

impl Ports
[src]

Create a new Ports

Example

let ports = try!(Ports::new("component".to_string(),
                       sched_sender,
                       vec!["input".to_string()], vec![],
                       vec!["output".to_string()], vec![]));
let sender = try!(ports.get_sender("input"));Run

Get the sender of a input ports

Example

let sender = try!(ports.get_sender("input"));
let ip = IP::new();
try!(sender.send(ip));Run

Get the sender of a input array ports

Example

let sender = try!(ports.get_sender("inputs", "1"));
let ip = IP::new();
try!(sender.send(ip));Run

Get the list of the current selections in a array input port

Example

let vec = try!(ports.get_input_selections("inputs"));
assert_eq!(vec.length(), 0);
try!(ports.add_input_selection("inputs", "1"));
try!(ports.add_input_selection("inputs", "2"));
let vec = try!(ports.get_input_selections("inputs"));
for i in vec {
    print!("{} ", i);
}
// Produce `1 2`Run

Get the list of the current selections in a array output port

Example

let vec = try!(ports.get_output_selections("outputs"));
assert_eq!(vec.length(), 0);
try!(ports.add_output_selection("outputs", "1"));
try!(ports.add_output_selection("outputs", "2"));
let vec = try!(ports.get_output_selections("outputs"));
for i in vec {
    print!("{} ", i);
}
// Produce `1 2`Run

Receive an IP from an input ports

Example

let ip = try!(ports.recv("input"));
println!("{}", ip.action);Run

Try to receive an IP from an input ports

Example

while let Ok(ip) = ports.try_recv("input") {
    println!("{}", ip.action);
}Run

Receive an IP from an array input ports

Example

let ip = try!(ports.recv_array("inputs", "1"));
println!("{}", ip.action);Run

Try to receive an IP from an array input ports

Example

while let Ok(ip) = ports.try_recv_array("input", "1") {
    println!("{}", ip.action);
}Run

Send an IP outside, through the output port port_out

Example

   let ip = IP::new();
   try!(ports.send("output", ip));Run

Send an IP outside, through the array output port port_out with the selection selection_out

Example

   let ip = IP::new();
   try!(ports.send_array("output", "1", ip));Run

Send an IP outside, depending of the action

The component must have a simple output port and an array output port with the same name (IE: output). If the array output port had a selection corresponding to the IP action, the IP will be send on it. Otherwise, the IP is send on the simple output port.

Example

try!(ports.add_output_selection("output", "1"));
let mut ip = IP::new();
ip.action = "2".to_string();
try!(send_action("output", ip)); // Send on the simple output port "output"
let mut ip = IP::new();
ip.action = "1".to_string();
try!(send_action("output", ip)); // Send on the array output port "output", selection "1"Run

Connect an simple output port with the IPSender

try!(ports.connect("output", sender));Run

Connect an array output port with the IPSender

try!(ports.connect_array("output", "1", sender));Run

Disconnect and retrieve the IPSender of an simple output port

let sender = try!(ports.disconnect("output"));Run

Disconnect and retrieve the IPSender of an array output port

let sender = try!(ports.disconnect_array("outputs", "1"));Run

Change the receiver of a simple output ports

usefull if you want to swap a component, but keep the existing connection

ports.set_receiver("input", receiver);Run

Get the receiver of a simple output ports

usefull if you want to swap a component, but keep the existing connection

let receiver = try!(ports.remove_receiver("input"));Run

Get the receiver of a array output ports

usefull if you want to swap a component, but keep the existing connection

let receiver = try!(ports.remove_array_receiver("inputs", "1"));Run

Add a selection in an input array port, and retrieve the corresponding IPSender

let sender = try!(ports.add_input_selection("inputs", "1"));Run

Change the receiver of an array output ports

usefull if you want to swap a component, but keep the existing connection

ports.add_input_receiver("input", receiver);Run

Add a selection in an input array port

This selection will be able to be connected to another component

try!(ports.add_output_selection("inputs", "1"));Run