-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathoptions.rs
More file actions
123 lines (102 loc) · 3.1 KB
/
options.rs
File metadata and controls
123 lines (102 loc) · 3.1 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use crate::proto::common::ConsistencyLevel;
#[derive(Debug, Clone, Copy)]
pub struct CreateCollectionOptions {
pub(crate) shard_num: i32,
pub(crate) consistency_level: ConsistencyLevel,
}
impl Default for CreateCollectionOptions {
fn default() -> Self {
Self {
shard_num: 0,
consistency_level: ConsistencyLevel::Bounded,
}
}
}
impl CreateCollectionOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_shard_num(shard_num: i32) -> Self {
Self::default().shard_num(shard_num)
}
pub fn with_consistency_level(consistency_level: ConsistencyLevel) -> Self {
Self::default().consistency_level(consistency_level)
}
pub fn shard_num(mut self, shard_num: i32) -> Self {
self.shard_num = shard_num;
self
}
pub fn consistency_level(mut self, consistency_level: ConsistencyLevel) -> Self {
self.consistency_level = consistency_level;
self
}
}
#[derive(Debug, Clone)]
pub struct LoadOptions {
pub(crate) replica_number: i32,
pub(crate) resource_groups: Vec<String>,
pub(crate) refresh: bool,
pub(crate) load_fields: Vec<String>,
pub(crate) skip_load_dynamic_field: bool,
pub(crate) load_params: std::collections::HashMap<String, String>,
}
impl Default for LoadOptions {
fn default() -> Self {
Self {
replica_number: 1,
resource_groups: vec![],
refresh: false,
load_fields: vec![],
skip_load_dynamic_field: false,
load_params: std::collections::HashMap::new(),
}
}
}
impl LoadOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_replica_number(replica_number: i32) -> Self {
Self::default().replica_number(replica_number)
}
pub fn replica_number(mut self, replica_number: i32) -> Self {
self.replica_number = replica_number;
self
}
pub fn resource_groups(mut self, resource_groups: Vec<String>) -> Self {
self.resource_groups = resource_groups;
self
}
pub fn refresh(mut self, refresh: bool) -> Self {
self.refresh = refresh;
self
}
pub fn load_fields(mut self, load_fields: Vec<String>) -> Self {
self.load_fields = load_fields;
self
}
pub fn skip_load_dynamic_field(mut self, skip_load_dynamic_field: bool) -> Self {
self.skip_load_dynamic_field = skip_load_dynamic_field;
self
}
pub fn load_params(mut self, load_params: std::collections::HashMap<String, String>) -> Self {
self.load_params = load_params;
self
}
}
#[derive(Debug, Clone, Default)]
pub struct GetLoadStateOptions {
pub(crate) partition_names: Vec<String>,
}
impl GetLoadStateOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_partition_names(partition_names: Vec<String>) -> Self {
Self::default().partition_names(partition_names)
}
pub fn partition_names(mut self, partition_names: Vec<String>) -> Self {
self.partition_names = partition_names;
self
}
}