Skip to main content

qdrant_client/builders/
id_tracker_params_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct IdTrackerParamsBuilder {
6    /// Memory placement of the point id mapping in indexed segments.
7    pub(crate) memory: Option<Option<i32>>,
8}
9
10impl Default for IdTrackerParamsBuilder {
11    fn default() -> Self {
12        Self::new()
13    }
14}
15
16impl IdTrackerParamsBuilder {
17    pub fn new() -> Self {
18        Self::create_empty()
19    }
20
21    /// Memory placement of the point id mapping in indexed segments:
22    /// [`Memory::Cold`] keeps it on disk and reads it on demand, [`Memory::Cached`] keeps it on disk
23    /// but primes the page cache with it on load, [`Memory::Pinned`] keeps it in RAM.
24    pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
25        let mut new = self;
26        new.memory = Option::Some(Option::Some(value.into()));
27        new
28    }
29
30    fn build_inner(self) -> Result<IdTrackerParams, std::convert::Infallible> {
31        Ok(IdTrackerParams {
32            memory: self.memory.unwrap_or_default(),
33        })
34    }
35    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
36    fn create_empty() -> Self {
37        Self {
38            memory: core::default::Default::default(),
39        }
40    }
41}
42
43impl From<IdTrackerParamsBuilder> for IdTrackerParams {
44    fn from(value: IdTrackerParamsBuilder) -> Self {
45        value.build_inner().unwrap_or_else(|_| {
46            panic!(
47                "Failed to convert {0} to {1}",
48                "IdTrackerParamsBuilder", "IdTrackerParams"
49            )
50        })
51    }
52}
53
54impl IdTrackerParamsBuilder {
55    /// Builds the desired type. Can often be omitted.
56    pub fn build(self) -> IdTrackerParams {
57        self.build_inner().unwrap_or_else(|_| {
58            panic!(
59                "Failed to build {0} into {1}",
60                "IdTrackerParamsBuilder", "IdTrackerParams"
61            )
62        })
63    }
64}