1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use rand;
use types::*;
use frame::*;
use query::QueryParams;
#[derive(Debug)]
pub struct BodyReqExecute<'a> {
id: &'a CBytesShort,
query_parameters: QueryParams,
}
impl<'a> BodyReqExecute<'a> {
pub fn new(id: &CBytesShort, query_parameters: QueryParams) -> BodyReqExecute {
BodyReqExecute { id: id,
query_parameters: query_parameters, }
}
}
impl<'a> IntoBytes for BodyReqExecute<'a> {
fn into_cbytes(&self) -> Vec<u8> {
let mut v: Vec<u8> = vec![];
v.extend_from_slice(self.id.into_cbytes().as_slice());
v.extend_from_slice(self.query_parameters.into_cbytes().as_slice());
v
}
}
impl Frame {
pub fn new_req_execute(id: &CBytesShort,
query_parameters: QueryParams,
flags: Vec<Flag>)
-> Frame {
let version = Version::Request;
let stream = rand::random::<u16>();
let opcode = Opcode::Execute;
debug!("prepared statement id{:?} getting executed with parameters {:?}",
id, query_parameters);
let body = BodyReqExecute::new(id, query_parameters);
Frame { version: version,
flags: flags,
stream: stream,
opcode: opcode,
body: body.into_cbytes(),
tracing_id: None,
warnings: vec![], }
}
}