rustfbp::component! [] [src]

macro_rules! component {
    (
       $name:ident, $( ( $($c_t:ident$(: $c_tr:ident)* ),* ),)*
        inputs($( $input_field_name:ident),* ),
        inputs_array($( $input_array_name:ident),* ),
        outputs($( $output_field_name:ident),* ),
        outputs_array($($output_array_name:ident),* ),
        fn run(&mut $arg:ident) $fun:block
        $($more:item)*
    ) => { ... };
}

Represent the default options simple input port

It is different from a classical Receiver because it :

  • Remember the last message received

  • If there is more than one message inside the channel, it keeps only the last one.

  • If there is no message in the channel, it sends the last one. If it is the first message, it block until there is a message

Example

let (s, r) = sync_channel(16);
let or = OptionReceiver::new(r);
s.send(23).unwrap();
assert_eq!(or.recv().unwrap(), 23);
assert_eq!(or.recv().unwrap(), 23);
s.send(42).unwrap();
s.send(666).unwrap();
assert_eq!(or.recv().unwrap(), 666);