cql3_parser/
begin_batch.rs1use std::fmt::{Display, Formatter};
2
3#[derive(PartialEq, Debug, Clone)]
4pub enum BatchType {
5 Logged,
6 Counter,
7 Unlogged,
8}
9
10#[derive(PartialEq, Debug, Clone)]
12pub struct BeginBatch {
13 pub ty: BatchType,
14 pub timestamp: Option<u64>,
16}
17
18impl Display for BeginBatch {
19 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
20 let modifiers = match self.ty {
21 BatchType::Logged => "",
22 BatchType::Counter => "COUNTER ",
23 BatchType::Unlogged => "UNLOGGED ",
24 };
25
26 if let Some(timestamp) = self.timestamp {
27 write!(f, "BEGIN {}BATCH USING TIMESTAMP {} ", modifiers, timestamp)
28 } else {
29 write!(f, "BEGIN {}BATCH ", modifiers)
30 }
31 }
32}