qdrant_client/builders/
create_shard_key_builder.rs1use crate::qdrant::*;
2
3pub struct CreateShardKeyBuilder {
4 pub(crate) shard_key: Option<Option<ShardKey>>,
6 pub(crate) shards_number: Option<Option<u32>>,
8 pub(crate) replication_factor: Option<Option<u32>>,
10 pub(crate) placement: Option<Vec<u64>>,
12}
13
14impl CreateShardKeyBuilder {
15 #[allow(unused_mut)]
17 pub fn shard_key<VALUE: core::convert::Into<ShardKey>>(self, value: VALUE) -> Self {
18 let mut new = self;
19 new.shard_key = Option::Some(Option::Some(value.into()));
20 new
21 }
22 #[allow(unused_mut)]
24 pub fn shards_number(self, value: u32) -> Self {
25 let mut new = self;
26 new.shards_number = Option::Some(Option::Some(value));
27 new
28 }
29 #[allow(unused_mut)]
31 pub fn replication_factor(self, value: u32) -> Self {
32 let mut new = self;
33 new.replication_factor = Option::Some(Option::Some(value));
34 new
35 }
36 #[allow(unused_mut)]
38 pub fn placement(self, value: Vec<u64>) -> Self {
39 let mut new = self;
40 new.placement = Option::Some(value);
41 new
42 }
43 fn build_inner(self) -> Result<CreateShardKey, std::convert::Infallible> {
44 Ok(CreateShardKey {
45 shard_key: self.shard_key.unwrap_or_default(),
46 shards_number: self.shards_number.unwrap_or_default(),
47 replication_factor: self.replication_factor.unwrap_or_default(),
48 placement: self.placement.unwrap_or_default(),
49 })
50 }
51 fn create_empty() -> Self {
53 Self {
54 shard_key: core::default::Default::default(),
55 shards_number: core::default::Default::default(),
56 replication_factor: core::default::Default::default(),
57 placement: core::default::Default::default(),
58 }
59 }
60}
61
62impl From<CreateShardKeyBuilder> for CreateShardKey {
63 fn from(value: CreateShardKeyBuilder) -> Self {
64 value.build_inner().unwrap_or_else(|_| {
65 panic!(
66 "Failed to convert {0} to {1}",
67 "CreateShardKeyBuilder", "CreateShardKey"
68 )
69 })
70 }
71}
72
73impl CreateShardKeyBuilder {
74 pub fn build(self) -> CreateShardKey {
76 self.build_inner().unwrap_or_else(|_| {
77 panic!(
78 "Failed to build {0} into {1}",
79 "CreateShardKeyBuilder", "CreateShardKey"
80 )
81 })
82 }
83}
84
85impl Default for CreateShardKeyBuilder {
86 fn default() -> Self {
87 Self::create_empty()
88 }
89}