Macro rustfbp::agent
[−]
[src]
macro_rules! agent { ( $( input($( $input_name:ident: $input_contract:ident ),*), )* $( inarr($( $input_a_name:ident: $input_a_contract:ident ),*), )* $( output($( $output_name:ident: $output_contract:ident ),*), )* $( outarr($( $output_a_name:ident: $output_a_contract:ident ),*), )* $( state( $state_type:ty => $state_value:expr ), )* $( option($option:ident), )* $( accumulator($accumulator:ident ), )* fn run(&mut $arg:ident) -> Result<Signal> $fun:block ) => { ... }; }
The agent macro.
It helps to define a agent, by defining the input and output ports, if there is an option or an acc port, ...
Example :
agent! { inputs(input: any), outputs(output: any), option(prim_text), fn run(&mut self) -> Result<Signal> { // Receive an IP let msg = try!(self.input.input.recv()); // Received an IP from the option port (a prim_text) let opt = self.recv_opt(); // Get the capn'p reader let reader: prim_text::Reader = try!(opt.read_schema()); // Print the option println!("{}", try!(reader.get_text())); // Send the received IP outside, but don't care about the success (drop on fail) let _ = self.output.output.send(msg); Ok(End) } }