qdrant_client/builders/
strict_mode_multivector_config_builder.rs1use std::collections::HashMap;
2
3use crate::qdrant::{StrictModeMultivector, StrictModeMultivectorConfig};
4
5#[derive(Clone)]
7pub struct StrictModeMultivectorConfigBuilder {
8 pub(crate) multivector_config: HashMap<String, StrictModeMultivector>,
10}
11
12impl StrictModeMultivectorConfigBuilder {
13 pub fn new() -> Self {
15 Self {
16 multivector_config: HashMap::new(),
17 }
18 }
19
20 pub fn add_vector_config<S: Into<String>>(
22 self,
23 name: S,
24 strict_mode_multivector: StrictModeMultivector,
25 ) -> Self {
26 let mut new = self;
27 let mut config = new.multivector_config;
28
29 config.insert(name.into(), strict_mode_multivector);
30
31 new.multivector_config = config;
32 new
33 }
34
35 pub fn multivector_config<M: Into<HashMap<String, StrictModeMultivector>>>(
37 self,
38 config: M,
39 ) -> Self {
40 let mut new = self;
41 new.multivector_config = config.into();
42 new
43 }
44
45 fn build_inner(self) -> Result<StrictModeMultivectorConfig, std::convert::Infallible> {
46 Ok(StrictModeMultivectorConfig {
47 multivector_config: self.multivector_config,
48 })
49 }
50
51 fn create_empty() -> Self {
53 Self {
54 multivector_config: core::default::Default::default(),
55 }
56 }
57}
58
59impl From<StrictModeMultivectorConfigBuilder> for StrictModeMultivectorConfig {
60 fn from(value: StrictModeMultivectorConfigBuilder) -> Self {
61 value.build_inner().unwrap_or_else(|_| {
62 panic!(
63 "Failed to convert {0} to {1}",
64 "StrictModeMultivectorConfigBuilder", "StrictModeMultivectorConfig"
65 )
66 })
67 }
68}
69
70impl StrictModeMultivectorConfigBuilder {
71 pub fn build(self) -> StrictModeMultivectorConfig {
73 self.build_inner().unwrap_or_else(|_| {
74 panic!(
75 "Failed to build {0} into {1}",
76 "StrictModeMultivectorConfigBuilder", "StrictModeMultivectorConfig"
77 )
78 })
79 }
80}
81
82impl Default for StrictModeMultivectorConfigBuilder {
83 fn default() -> Self {
84 Self::create_empty()
85 }
86}