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