add void method support (#1540)

This commit is contained in:
Nikolay Volf
2016-07-05 12:11:09 +04:00
committed by Arkadiy Paronyan
parent a25eb4b046
commit 1ab2060afa
3 changed files with 52 additions and 13 deletions

View File

@@ -190,4 +190,20 @@ mod tests {
assert_eq!(struct_, new_struct);
}
#[test]
fn can_call_void_method() {
let mut socket = TestSocket::new();
socket.read_buffer = vec![1];
let service_client = ServiceClient::init(socket);
service_client.void(99);
assert_eq!(vec![
0, 19,
0, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
99, 0, 0, 0, 0, 0, 0, 0],
service_client.socket().write().unwrap().write_buffer.clone());
}
}

View File

@@ -39,12 +39,14 @@ impl Service {
*lock = *lock + f as usize;
f
}
pub fn rollback(&self, a: Option<u32>, b: u32) -> i32 {
let a_0 = a.unwrap_or_else(|| 0);
let mut lock = self.rollbacks.write().unwrap();
*lock = *lock + a_0 as usize - b as usize;
(a_0 - b) as i32
}
pub fn push_custom(&self, data: CustomData) -> bool {
let mut clock = self.commits.write().unwrap();
let mut rlock = self.commits.write().unwrap();
@@ -54,6 +56,9 @@ impl Service {
true
}
pub fn void(&self, a: u64) {
}
}
impl Service {