@@ -64,14 +64,14 @@ impl InfoBuilder {
6464 }
6565}
6666
67- pub trait ParticipantTrait : Sync {
67+ pub trait Participant : Sync {
6868 fn info ( & self ) -> Info ;
6969 fn process ( & self , Vec < u8 > ) -> Result < Vec < u8 > , Vec < u8 > > ;
7070}
7171
72- struct Participant {
72+ struct ParticipantData {
7373 info : Info ,
74- _trait : & ' static ParticipantTrait ,
74+ _trait : & ' static Participant ,
7575}
7676
7777struct Connection {
@@ -100,7 +100,7 @@ fn send_discovery(channel: &mut Channel, info: &Info) {
100100}
101101
102102struct PortConsumer {
103- participant : & ' static ParticipantTrait ,
103+ participant : & ' static Participant ,
104104 portname : String ,
105105 outqueue : String , // FIXME: allow sending on any port, also multiple times
106106}
@@ -143,7 +143,7 @@ impl Consumer for PortConsumer {
143143}
144144
145145// FIXME: actually call ProcessFunction
146- fn setup_inport ( participant : & Participant , port : & Port , connection : & mut Connection ) {
146+ fn setup_inport ( participant : & ParticipantData , port : & Port , connection : & mut Connection ) {
147147 debug ! ( "setup inport: {}" , port. queue. to_string( ) ) ;
148148
149149 let consumer = PortConsumer {
@@ -166,7 +166,7 @@ fn setup_inport(participant: &Participant, port: &Port, connection: &mut Connect
166166 debug ! ( "inport setup done: {:?}, {:?}" , port. id. to_string( ) , port. queue. to_string( ) ) ;
167167}
168168
169- fn setup_outport ( participant : & Participant , port : & Port , connection : & mut Connection ) {
169+ fn setup_outport ( participant : & ParticipantData , port : & Port , connection : & mut Connection ) {
170170
171171 let exchange_type = "fanout" . to_string ( ) ;
172172 let declare = connection. channel . exchange_declare ( port. queue . to_string ( ) , exchange_type,
@@ -177,24 +177,25 @@ fn setup_outport(participant: &Participant, port: &Port, connection: &mut Connec
177177}
178178
179179
180- fn start_participant ( participant : & Participant , options : & Options ) -> Connection {
180+ fn start_participant ( participant : & ParticipantData , options : & Options ) -> Connection {
181181
182182 let mut session = Session :: open_url ( & options. broker ) . expect ( "Can't create AMQP session" ) ;
183183 let mut channel = session. open_channel ( 1 ) . expect ( "could not open AMQP channel" ) ;
184184
185185 let mut conn = Connection { session : session, channel : channel } ;
186+ let info = & participant. info ;
186187
187188 // setup ports
188- setup_inport ( & participant, & participant . info . inports [ 0 ] , & mut conn) ;
189- setup_outport ( & participant, & participant . info . outports [ 0 ] , & mut conn) ;
189+ setup_inport ( & participant, & info. inports [ 0 ] , & mut conn) ;
190+ setup_outport ( & participant, & info. outports [ 0 ] , & mut conn) ;
190191
191192 // send MsgFlo participant discovery message
192- send_discovery ( & mut conn. channel , & participant . info ) ;
193+ send_discovery ( & mut conn. channel , info) ;
193194
194195 return conn;
195196}
196197
197- fn stop_participant ( participant : & Participant , connection : & mut Connection ) {
198+ fn stop_participant ( participant : & ParticipantData , connection : & mut Connection ) {
198199
199200 let closed = connection. channel . close ( 200 , "Bye" . to_string ( ) ) ;
200201 connection. session . close ( 200 , "Good Bye" . to_string ( ) ) ;
@@ -270,18 +271,19 @@ fn parse(options: &mut Options) {
270271// XXX: seems rust-amqp makes program hangs forever if error occurs / channel is borked?
271272// TODO: pass port info in/out of process()
272273// TODO: nicer way to declare ports? ideally they are enums not stringly typed?
273- pub fn main ( orig : & ' static ParticipantTrait ) {
274+ pub fn main ( orig : & ' static Participant ) {
274275
275276 let mut options = Options { .. Default :: default ( ) } ;
276277 parse ( & mut options) ;
277278
278279 let i : Info = orig. info ( ) ;
279280 let info = normalize_info ( & i, & options) ;
280281
281- let p = Participant { info : info, _trait : orig } ; // XXX: hack
282+ let p = ParticipantData { info : info, _trait : orig } ; // XXX: hack
282283
283284 let mut c = start_participant ( & p, & options) ;
284- println ! ( "{}({}) started" , & p. info. role, & p. info. component) ;
285+
286+ println ! ( "{}({}) started" , p. info. role, p. info. component) ;
285287 c. channel . start_consuming ( ) ;
286288
287289 stop_participant ( & p, & mut c) ;
0 commit comments