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
19pub fn parse_key_range(s: &str) -> Result<(Bound<CowVec<u8>>, Bound<CowVec<u8>>), Box<dyn Error>> {
21 let mut bound = (Bound::<CowVec<u8>>::Unbounded, Bound::<CowVec<u8>>::Unbounded);
22
23 if let Some(dot_pos) = s.find("..") {
24 let start_part = &s[..dot_pos];
25 let end_part = &s[dot_pos + 2..];
26
27 if !start_part.is_empty() {
29 bound.0 = Bound::Included(decode_binary(start_part));
30 }
31
32 if let Some(end_str) = end_part.strip_prefix('=') {
34 if !end_str.is_empty() {
35 bound.1 = Bound::Included(decode_binary(end_str));
36 }
37 } else if !end_part.is_empty() {
38 bound.1 = Bound::Excluded(decode_binary(end_part));
39 }
40
41 Ok(bound)
42 } else {
43 Err(format!("invalid range {s}").into())
44 }
45}