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