pub mod conf;
pub mod r#impl;
pub mod key;
pub mod meta;
pub mod traits;
pub use conf::*;
pub use r#impl::*;
pub use key::{
member as compose_zset_key, meta as compose_zset_meta_key, prefix as compose_zset_prefix,
score as compose_zset_score_key, score_prefix as compose_zset_score_prefix,
};
pub use meta::*;
pub use traits::ZSet;
pub type ZSetMemberScore = (Vec<u8>, f64);
pub type ZSetKeyMemberScore = (Vec<u8>, Vec<u8>, f64);
pub type ZScanResult = (u64, Vec<ZSetMemberScore>);
use std::ops::Bound;
use crate::{error::Result, meta::parse_redis_float};
pub fn parse_score_bound(s: &str) -> Result<Bound<f64>> {
let s = s.trim();
if s == "+inf" {
return Ok(Bound::Unbounded);
}
if s == "-inf" {
return Ok(Bound::Unbounded);
}
if let Some(rest) = s.strip_prefix('(') {
let val = parse_redis_float(rest.as_bytes(), "ERR min or max is not a float")?;
Ok(Bound::Excluded(val))
} else if let Some(rest) = s.strip_prefix('[') {
let val = parse_redis_float(rest.as_bytes(), "ERR min or max is not a float")?;
Ok(Bound::Included(val))
} else {
let val = parse_redis_float(s.as_bytes(), "ERR min or max is not a float")?;
Ok(Bound::Included(val))
}
}