cassandra_proto/frame/
frame_prepare.rs1use rand;
2
3use crate::types::*;
4use crate::frame::*;
5
6#[derive(Debug)]
8pub struct BodyReqPrepare {
9 query: CStringLong,
10}
11
12impl BodyReqPrepare {
13 pub fn new(query: String) -> BodyReqPrepare {
15 BodyReqPrepare { query: CStringLong::new(query), }
16 }
17}
18
19impl IntoBytes for BodyReqPrepare {
20 fn into_cbytes(&self) -> Vec<u8> {
21 self.query.into_cbytes()
22 }
23}
24
25impl Frame {
26 pub fn new_req_prepare(query: String, flags: Vec<Flag>) -> Frame {
28 let version = Version::Request;
29 let stream = rand::random::<u16>();
30 let opcode = Opcode::Prepare;
31 let body = BodyReqPrepare::new(query);
32
33 Frame { version: version,
34 flags: flags,
35 stream: stream,
36 opcode: opcode,
37 body: body.into_cbytes(),
38 tracing_id: None,
40 warnings: vec![], }
41 }
42}