Skip to main content

qdrant_client/builders/
payload_storage_params_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct PayloadStorageParamsBuilder {
6    /// Memory placement of the payload storage.
7    pub(crate) memory: Option<Option<i32>>,
8}
9
10impl Default for PayloadStorageParamsBuilder {
11    fn default() -> Self {
12        Self::new()
13    }
14}
15
16impl PayloadStorageParamsBuilder {
17    pub fn new() -> Self {
18        Self::create_empty()
19    }
20
21    /// Memory placement of the payload storage.
22    /// Overrides the deprecated `on_disk_payload` flag if both are set.
23    /// [`Memory::Pinned`] is not supported for payload storage.
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<PayloadStorageParams, std::convert::Infallible> {
31        Ok(PayloadStorageParams {
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<PayloadStorageParamsBuilder> for PayloadStorageParams {
44    fn from(value: PayloadStorageParamsBuilder) -> Self {
45        value.build_inner().unwrap_or_else(|_| {
46            panic!(
47                "Failed to convert {0} to {1}",
48                "PayloadStorageParamsBuilder", "PayloadStorageParams"
49            )
50        })
51    }
52}
53
54impl PayloadStorageParamsBuilder {
55    /// Builds the desired type. Can often be omitted.
56    pub fn build(self) -> PayloadStorageParams {
57        self.build_inner().unwrap_or_else(|_| {
58            panic!(
59                "Failed to build {0} into {1}",
60                "PayloadStorageParamsBuilder", "PayloadStorageParams"
61            )
62        })
63    }
64}