qdrant_client/builders/
geo_index_params_builder.rs1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct GeoIndexParamsBuilder {
6 pub(crate) on_disk: Option<Option<bool>>,
8 pub(crate) enable_hnsw: Option<Option<bool>>,
10 pub(crate) memory: Option<Option<i32>>,
12}
13
14impl Default for GeoIndexParamsBuilder {
15 fn default() -> Self {
16 Self::new()
17 }
18}
19
20impl GeoIndexParamsBuilder {
21 pub fn new() -> Self {
22 Self::create_empty()
23 }
24
25 pub fn on_disk(self, value: bool) -> Self {
29 let mut new = self;
30 new.on_disk = Option::Some(Option::Some(value));
31 new
32 }
33 pub fn enable_hnsw(self, value: bool) -> Self {
35 let mut new = self;
36 new.enable_hnsw = Option::Some(Option::Some(value));
37 new
38 }
39 pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
42 let mut new = self;
43 new.memory = Option::Some(Option::Some(value.into()));
44 new
45 }
46
47 #[allow(deprecated)]
48 fn build_inner(self) -> Result<GeoIndexParams, std::convert::Infallible> {
49 Ok(GeoIndexParams {
50 on_disk: self.on_disk.unwrap_or_default(),
51 enable_hnsw: self.enable_hnsw.unwrap_or_default(),
52 memory: self.memory.unwrap_or_default(),
53 })
54 }
55 fn create_empty() -> Self {
57 Self {
58 on_disk: core::default::Default::default(),
59 enable_hnsw: core::default::Default::default(),
60 memory: core::default::Default::default(),
61 }
62 }
63}
64
65impl From<GeoIndexParamsBuilder> for GeoIndexParams {
66 fn from(value: GeoIndexParamsBuilder) -> Self {
67 value.build_inner().unwrap_or_else(|_| {
68 panic!(
69 "Failed to convert {0} to {1}",
70 "GeoIndexParamsBuilder", "GeoIndexParams"
71 )
72 })
73 }
74}
75
76impl GeoIndexParamsBuilder {
77 pub fn build(self) -> GeoIndexParams {
79 self.build_inner().unwrap_or_else(|_| {
80 panic!(
81 "Failed to build {0} into {1}",
82 "GeoIndexParamsBuilder", "GeoIndexParams"
83 )
84 })
85 }
86}