@@ -66,13 +66,11 @@ impl InfoBuilder {
6666
6767pub trait ParticipantTrait : Sync {
6868 fn info ( & self ) -> Info ;
69- // fn process(&self, Vec<u8>) -> Result<Vec<u8>, Vec<u8>>;
69+ fn process ( & self , Vec < u8 > ) -> Result < Vec < u8 > , Vec < u8 > > ;
7070}
71- pub type ProcessFunction = fn ( & ParticipantTrait , Vec < u8 > ) -> Result < Vec < u8 > , Vec < u8 > > ;
7271
7372struct Participant {
7473 info : Info ,
75- process : ProcessFunction ,
7674 _trait : & ' static ParticipantTrait ,
7775}
7876
@@ -102,7 +100,6 @@ fn send_discovery(channel: &mut Channel, info: &Info) {
102100}
103101
104102struct PortConsumer {
105- process : ProcessFunction ,
106103 participant : & ' static ParticipantTrait ,
107104 portname : String ,
108105 outqueue : String , // FIXME: allow sending on any port, also multiple times
@@ -130,8 +127,7 @@ impl Consumer for PortConsumer {
130127 body : Vec < u8 > ) {
131128
132129 debug ! ( "calling process()" ) ;
133- let f = self . process ;
134- let res = f ( self . participant , body) ;
130+ let res = self . participant . process ( body) ;
135131 debug ! ( "process() returned" ) ;
136132
137133 if res. is_ok ( ) {
@@ -151,7 +147,6 @@ fn setup_inport(participant: &Participant, port: &Port, connection: &mut Connect
151147 debug ! ( "setup inport: {}" , port. queue. to_string( ) ) ;
152148
153149 let consumer = PortConsumer {
154- process : participant. process ,
155150 participant : participant. _trait ,
156151 portname : port. id . to_string ( ) ,
157152 outqueue : participant. info . outports [ 0 ] . queue . to_string ( ) ,
@@ -275,15 +270,15 @@ fn parse(options: &mut Options) {
275270// XXX: seems rust-amqp makes program hangs forever if error occurs / channel is borked?
276271// TODO: pass port info in/out of process()
277272// TODO: nicer way to declare ports? ideally they are enums not stringly typed?
278- pub fn main ( orig : & ' static ParticipantTrait , func : ProcessFunction ) {
273+ pub fn main ( orig : & ' static ParticipantTrait ) {
279274
280275 let mut options = Options { .. Default :: default ( ) } ;
281276 parse ( & mut options) ;
282277
283278 let i : Info = orig. info ( ) ;
284279 let info = normalize_info ( & i, & options) ;
285280
286- let p = Participant { info : info, process : func , _trait : orig } ; // XXX: hack
281+ let p = Participant { info : info, _trait : orig } ; // XXX: hack
287282
288283 let mut c = start_participant ( & p, & options) ;
289284 println ! ( "{}({}) started" , & p. info. role, & p. info. component) ;
0 commit comments