Upgrading vendor folder dependencies.

This commit is contained in:
Renan DelValle 2018-12-27 09:58:53 -08:00
parent 4a0cbcd770
commit acbe9ad9e5
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
229 changed files with 10735 additions and 4528 deletions

View file

@ -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
@ -81,7 +81,7 @@ fn run() -> thrift::Result<()> {
// ok - let's be bad :(
// do a divide by 0
// logid doesn't matter; won't be recorded
let res = client.calculate(77, Work::new(2, 0, Operation::DIVIDE, "we bad".to_owned()));
let res = client.calculate(77, Work::new(2, 0, Operation::Divide, "we bad".to_owned()));
// we should have gotten an exception back
match res {
@ -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>> {

View file

@ -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,29 +126,25 @@ 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");
let num2 = w.num2.as_ref().expect("operands checked");
match *op {
Operation::ADD => Ok(num1 + num2),
Operation::SUBTRACT => Ok(num1 - num2),
Operation::MULTIPLY => Ok(num1 * num2),
Operation::DIVIDE => {
Operation::Add => Ok(num1 + num2),
Operation::Subtract => Ok(num1 - num2),
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