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