CaS predicate bounds
Current implementation of cas::Predicate implies inclusive ranges and doesn't let to specify excluded or unbounded ranges.
Let's refactor the API according to the proposal: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e64790625d5f5627f56b50c103126241
diff --git a/src/traft/rpc/cas.rs b/src/traft/rpc/cas.rs
index f077bdd9..47f0952e 100644
--- a/src/traft/rpc/cas.rs
+++ b/src/traft/rpc/cas.rs
@@ -291,10 +291,15 @@ pub struct Predicate {
pub struct Range {
pub space: String,
pub index: String,
- #[serde(with = "serde_bytes")]
- pub key_min: TupleBuffer,
- #[serde(with = "serde_bytes")]
- pub key_max: TupleBuffer,
+ pub key_min: Bound<TupleBuffer>,
+ pub key_max: Bound<TupleBuffer>,
}
+#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
+pub enum Bound<T> {
+ Included(T),
+ Excluded(T),
+ Unbounded,
+}