qdrant_client/builders/
sparse_vector_params_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct SparseVectorParamsBuilder {
5 pub(crate) index: Option<Option<SparseIndexConfig>>,
7 pub(crate) modifier: Option<Option<i32>>,
9}
10
11impl SparseVectorParamsBuilder {
12 #[allow(unused_mut)]
14 pub fn index<VALUE: core::convert::Into<SparseIndexConfig>>(self, value: VALUE) -> Self {
15 let mut new = self;
16 new.index = Option::Some(Option::Some(value.into()));
17 new
18 }
19 #[allow(unused_mut)]
21 pub fn modifier<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
22 let mut new = self;
23 new.modifier = Option::Some(Option::Some(value.into()));
24 new
25 }
26
27 fn build_inner(self) -> Result<SparseVectorParams, std::convert::Infallible> {
28 Ok(SparseVectorParams {
29 index: self.index.unwrap_or_default(),
30 modifier: self.modifier.unwrap_or_default(),
31 })
32 }
33 fn create_empty() -> Self {
35 Self {
36 index: core::default::Default::default(),
37 modifier: core::default::Default::default(),
38 }
39 }
40}
41
42impl From<SparseVectorParamsBuilder> for SparseVectorParams {
43 fn from(value: SparseVectorParamsBuilder) -> Self {
44 value.build_inner().unwrap_or_else(|_| {
45 panic!(
46 "Failed to convert {0} to {1}",
47 "SparseVectorParamsBuilder", "SparseVectorParams"
48 )
49 })
50 }
51}
52
53impl SparseVectorParamsBuilder {
54 pub fn build(self) -> SparseVectorParams {
56 self.build_inner().unwrap_or_else(|_| {
57 panic!(
58 "Failed to build {0} into {1}",
59 "SparseVectorParamsBuilder", "SparseVectorParams"
60 )
61 })
62 }
63}
64
65impl Default for SparseVectorParamsBuilder {
66 fn default() -> Self {
67 Self::create_empty()
68 }
69}