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 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 pub fn modifier<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
20 let mut new = self;
21 new.modifier = Option::Some(Option::Some(value.into()));
22 new
23 }
24
25 fn build_inner(self) -> Result<SparseVectorParams, std::convert::Infallible> {
26 Ok(SparseVectorParams {
27 index: self.index.unwrap_or_default(),
28 modifier: self.modifier.unwrap_or_default(),
29 })
30 }
31 fn create_empty() -> Self {
33 Self {
34 index: core::default::Default::default(),
35 modifier: core::default::Default::default(),
36 }
37 }
38}
39
40impl From<SparseVectorParamsBuilder> for SparseVectorParams {
41 fn from(value: SparseVectorParamsBuilder) -> Self {
42 value.build_inner().unwrap_or_else(|_| {
43 panic!(
44 "Failed to convert {0} to {1}",
45 "SparseVectorParamsBuilder", "SparseVectorParams"
46 )
47 })
48 }
49}
50
51impl SparseVectorParamsBuilder {
52 pub fn build(self) -> SparseVectorParams {
54 self.build_inner().unwrap_or_else(|_| {
55 panic!(
56 "Failed to build {0} into {1}",
57 "SparseVectorParamsBuilder", "SparseVectorParams"
58 )
59 })
60 }
61}
62
63impl Default for SparseVectorParamsBuilder {
64 fn default() -> Self {
65 Self::create_empty()
66 }
67}