Last active
December 30, 2016 03:54
-
-
Save allengeorge/590515b0db868d4b29c0fb908a0efeeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0308]: mismatched types | |
--> src/base_two.rs:453:49 | |
| | |
453 | TRamenServiceActualProcessor::process_ramen(self.handler, incoming_sequence_number, i_prot, o_prot) | |
| ^^^^^^^^^^^^ expected &mut _, found type parameter | |
| | |
= note: expected type `&mut _` | |
= note: found type `H` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RamenService service server | |
// | |
pub trait TRamenServiceSyncHandler : TNapkinServiceSyncHandler { | |
fn handle_ramen(&mut self, requested_noodle_count: i32) -> rift::Result<Ramen>; | |
} | |
pub struct TRamenServiceProcessor<H: TRamenServiceSyncHandler> { | |
handler: H, | |
} | |
impl <H: TRamenServiceSyncHandler> TRamenServiceProcessor<H> { | |
pub fn new(handler: H) -> TRamenServiceProcessor<H> { | |
TRamenServiceProcessor { | |
handler: handler, | |
} | |
} | |
fn process_ramen(&mut self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> rift::Result<()> { | |
TRamenServiceActualProcessor::process_ramen(self.handler, incoming_sequence_number, i_prot, o_prot) | |
} | |
fn process_napkin(&mut self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> rift::Result<()> { | |
TNapkinServiceActualProcessor::process_napkin(self.handler, incoming_sequence_number, i_prot, o_prot) | |
} | |
} | |
pub struct TRamenServiceActualProcessor; | |
impl TRamenServiceActualProcessor { | |
pub fn process_ramen<H: TRamenServiceSyncHandler>(handler: &mut H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> rift::Result<()> { | |
let args = try!(RamenArgs::read_from_in_protocol(i_prot)); | |
match handler.handle_ramen(args.requested_noodle_count) { | |
Ok(handler_return) => { | |
let message_ident = TMessageIdentifier::new("ramen", TMessageType::Reply, incoming_sequence_number); | |
try!(o_prot.write_message_begin(&message_ident)); | |
let ret = RamenResult { result_value: Some(handler_return) }; | |
try!(ret.write_to_out_protocol(o_prot)); | |
try!(o_prot.write_message_end()); | |
o_prot.flush() | |
}, | |
Err(e) => { | |
match e { | |
_ => { | |
let ret_err = { | |
ApplicationError { | |
kind: ApplicationErrorKind::Unknown, | |
message: e.description().to_owned(), | |
} | |
}; | |
let message_ident = TMessageIdentifier::new("ramen", TMessageType::Exception, incoming_sequence_number); | |
try!(o_prot.write_message_begin(&message_ident)); | |
try!(rift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)); | |
try!(o_prot.write_message_end()); | |
o_prot.flush() | |
}, | |
} | |
}, | |
} | |
} | |
} | |
impl <H: TRamenServiceSyncHandler> TProcessor for TRamenServiceProcessor<H> { | |
fn process(&mut self, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> rift::Result<()> { | |
let message_ident = try!(i_prot.read_message_begin()); | |
match &*message_ident.name { | |
"ramen" => { | |
self.process_ramen(message_ident.sequence_number, i_prot, o_prot) | |
}, | |
"napkin" => { | |
self.process_napkin(message_ident.sequence_number, i_prot, o_prot) | |
}, | |
method => { | |
Err( | |
rift::Error::Application( | |
ApplicationError { | |
kind: ApplicationErrorKind::UnknownMethod, | |
message: format!("unknown method {}", method), | |
} | |
) | |
) | |
}, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment