reifydb_testing/util/
mod.rs1pub mod wait;
13
14use std::{error::Error, ops::Bound};
15
16use reifydb_core::util::encoding::binary::decode_binary;
17use reifydb_type::util::cowvec::CowVec;
18
19type KeyRange = (Bound<CowVec<u8>>, Bound<CowVec<u8>>);
20
21pub fn parse_key_range(s: &str) -> Result<KeyRange, Box<dyn Error>> {
23 let mut bound = (Bound::<CowVec<u8>>::Unbounded, Bound::<CowVec<u8>>::Unbounded);
24
25 if let Some(dot_pos) = s.find("..") {
26 let start_part = &s[..dot_pos];
27 let end_part = &s[dot_pos + 2..];
28
29 if !start_part.is_empty() {
31 bound.0 = Bound::Included(decode_binary(start_part));
32 }
33
34 if let Some(end_str) = end_part.strip_prefix('=') {
36 if !end_str.is_empty() {
37 bound.1 = Bound::Included(decode_binary(end_str));
38 }
39 } else if !end_part.is_empty() {
40 bound.1 = Bound::Excluded(decode_binary(end_part));
41 }
42
43 Ok(bound)
44 } else {
45 Err(format!("invalid range {s}").into())
46 }
47}