use rand;
use crate::frame::*;
use crate::types::*;
#[derive(Debug)]
pub struct BodyReqPrepare {
query: CStringLong,
}
impl BodyReqPrepare {
pub fn new(query: String) -> BodyReqPrepare {
BodyReqPrepare {
query: CStringLong::new(query),
}
}
}
impl IntoBytes for BodyReqPrepare {
fn into_cbytes(&self) -> Vec<u8> {
self.query.into_cbytes()
}
}
impl Frame {
pub fn new_req_prepare(query: String, flags: Vec<Flag>) -> Frame {
let version = Version::Request;
let stream = rand::random::<u16>();
let opcode = Opcode::Prepare;
let body = BodyReqPrepare::new(query);
Frame {
version: version,
flags: flags,
stream: stream,
opcode: opcode,
body: body.into_cbytes(),
tracing_id: None,
warnings: vec![],
}
}
}