diff options
author | Allen George <allen.george@gmail.com> | 2018-12-16 18:01:37 -0500 |
---|---|---|
committer | GREATEST Wiggler EvaR! <allen@actioniq.com> | 2018-12-16 18:22:04 -0500 |
commit | ef7a18970f309632e3a3015ac1c659d72d36967b (patch) | |
tree | fbffe5b4701a2fc2ceec4d0d0b80b8384cd5aee7 /tutorial | |
parent | 2b7365c54f823013cc6a4760798051b22743c103 (diff) | |
download | thrift-ef7a18970f309632e3a3015ac1c659d72d36967b.tar.gz |
Reformat rust code with rustfmt 1.0
Diffstat (limited to 'tutorial')
-rw-r--r-- | tutorial/rs/src/bin/tutorial_client.rs | 11 | ||||
-rw-r--r-- | tutorial/rs/src/bin/tutorial_server.rs | 33 |
2 files changed, 23 insertions, 21 deletions
diff --git a/tutorial/rs/src/bin/tutorial_client.rs b/tutorial/rs/src/bin/tutorial_client.rs index e7192b616..c80fafc2f 100644 --- a/tutorial/rs/src/bin/tutorial_client.rs +++ b/tutorial/rs/src/bin/tutorial_client.rs @@ -22,8 +22,9 @@ extern crate thrift; extern crate thrift_tutorial; use thrift::protocol::{TCompactInputProtocol, TCompactOutputProtocol}; -use thrift::transport::{ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel, - TTcpChannel, WriteHalf}; +use thrift::transport::{ + ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel, TTcpChannel, WriteHalf, +}; use thrift_tutorial::shared::TSharedServiceSyncClient; use thrift_tutorial::tutorial::{CalculatorSyncClient, Operation, TCalculatorSyncClient, Work}; @@ -70,8 +71,7 @@ fn run() -> thrift::Result<()> { let logid = 32; // let's do...a multiply! - let res = client - .calculate(logid, Work::new(7, 8, Operation::Multiply, None))?; + let res = client.calculate(logid, Work::new(7, 8, Operation::Multiply, None))?; println!("multiplied 7 and 8 and got {}", res); // let's get the log for it @@ -103,8 +103,7 @@ fn run() -> thrift::Result<()> { type ClientInputProtocol = TCompactInputProtocol<TFramedReadTransport<ReadHalf<TTcpChannel>>>; type ClientOutputProtocol = TCompactOutputProtocol<TFramedWriteTransport<WriteHalf<TTcpChannel>>>; -fn new_client - ( +fn new_client( host: &str, port: u16, ) -> thrift::Result<CalculatorSyncClient<ClientInputProtocol, ClientOutputProtocol>> { diff --git a/tutorial/rs/src/bin/tutorial_server.rs b/tutorial/rs/src/bin/tutorial_server.rs index 171c4ce31..95b1a2b6e 100644 --- a/tutorial/rs/src/bin/tutorial_server.rs +++ b/tutorial/rs/src/bin/tutorial_server.rs @@ -65,7 +65,9 @@ fn run() -> thrift::Result<()> { let o_prot_fact = TCompactOutputProtocolFactory::new(); // demux incoming messages - let processor = CalculatorSyncProcessor::new(CalculatorServer { ..Default::default() }); + let processor = CalculatorSyncProcessor::new(CalculatorServer { + ..Default::default() + }); // create the server and start listening let mut server = TServer::new( @@ -87,7 +89,9 @@ struct CalculatorServer { impl Default for CalculatorServer { fn default() -> CalculatorServer { - CalculatorServer { log: Mutex::new(HashMap::new()) } + CalculatorServer { + log: Mutex::new(HashMap::new()), + } } } @@ -122,12 +126,10 @@ impl CalculatorSyncHandler for CalculatorServer { let res = if let Some(ref op) = w.op { if w.num1.is_none() || w.num2.is_none() { - Err( - InvalidOperation { - what_op: Some(*op as i32), - why: Some("no operands specified".to_owned()), - }, - ) + Err(InvalidOperation { + what_op: Some(*op as i32), + why: Some("no operands specified".to_owned()), + }) } else { // so that I don't have to call unwrap() multiple times below let num1 = w.num1.as_ref().expect("operands checked"); @@ -139,12 +141,10 @@ impl CalculatorSyncHandler for CalculatorServer { Operation::Multiply => Ok(num1 * num2), Operation::Divide => { if *num2 == 0 { - Err( - InvalidOperation { - what_op: Some(*op as i32), - why: Some("divide by 0".to_owned()), - }, - ) + Err(InvalidOperation { + what_op: Some(*op as i32), + why: Some("divide by 0".to_owned()), + }) } else { Ok(num1 / num2) } @@ -152,7 +152,10 @@ impl CalculatorSyncHandler for CalculatorServer { } } } else { - Err(InvalidOperation::new(None, "no operation specified".to_owned()),) + Err(InvalidOperation::new( + None, + "no operation specified".to_owned(), + )) }; // if the operation was successful log it |