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