forked from RedisJSON/RedisJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect_value.rs
38 lines (34 loc) · 1.15 KB
/
select_value.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright Redis Ltd. 2016 - present
* Licensed under your choice of the Redis Source Available License 2.0 (RSALv2) or
* the Server Side Public License v1 (SSPLv1).
*/
use serde::Serialize;
use std::fmt::Debug;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SelectValueType {
Null,
Bool,
Long,
Double,
String,
Array,
Object,
}
pub trait SelectValue: Debug + Eq + PartialEq + Default + Clone + Serialize {
fn get_type(&self) -> SelectValueType;
fn contains_key(&self, key: &str) -> bool;
fn values<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a Self> + 'a>>;
fn keys<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a str> + 'a>>;
fn items<'a>(&'a self) -> Option<Box<dyn Iterator<Item = (&'a str, &'a Self)> + 'a>>;
fn len(&self) -> Option<usize>;
fn is_empty(&self) -> Option<bool>;
fn get_key<'a>(&'a self, key: &str) -> Option<&'a Self>;
fn get_index(&self, index: usize) -> Option<&Self>;
fn is_array(&self) -> bool;
fn get_str(&self) -> String;
fn as_str(&self) -> &str;
fn get_bool(&self) -> bool;
fn get_long(&self) -> i64;
fn get_double(&self) -> f64;
}