qdrant-client 1.17.0

Rust client for Qdrant Vector Search Engine
Documentation
use crate::qdrant::*;

#[derive(Clone)]
pub struct SparseVectorParamsBuilder {
    /// Configuration of sparse index
    pub(crate) index: Option<Option<SparseIndexConfig>>,
    /// If set - apply modifier to the vector values
    pub(crate) modifier: Option<Option<i32>>,
}

impl SparseVectorParamsBuilder {
    /// Configuration of sparse index
    pub fn index<VALUE: core::convert::Into<SparseIndexConfig>>(self, value: VALUE) -> Self {
        let mut new = self;
        new.index = Option::Some(Option::Some(value.into()));
        new
    }
    /// If set - apply modifier to the vector values
    pub fn modifier<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
        let mut new = self;
        new.modifier = Option::Some(Option::Some(value.into()));
        new
    }

    fn build_inner(self) -> Result<SparseVectorParams, std::convert::Infallible> {
        Ok(SparseVectorParams {
            index: self.index.unwrap_or_default(),
            modifier: self.modifier.unwrap_or_default(),
        })
    }
    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
    fn create_empty() -> Self {
        Self {
            index: core::default::Default::default(),
            modifier: core::default::Default::default(),
        }
    }
}

impl From<SparseVectorParamsBuilder> for SparseVectorParams {
    fn from(value: SparseVectorParamsBuilder) -> Self {
        value.build_inner().unwrap_or_else(|_| {
            panic!(
                "Failed to convert {0} to {1}",
                "SparseVectorParamsBuilder", "SparseVectorParams"
            )
        })
    }
}

impl SparseVectorParamsBuilder {
    /// Builds the desired type. Can often be omitted.
    pub fn build(self) -> SparseVectorParams {
        self.build_inner().unwrap_or_else(|_| {
            panic!(
                "Failed to build {0} into {1}",
                "SparseVectorParamsBuilder", "SparseVectorParams"
            )
        })
    }
}

impl Default for SparseVectorParamsBuilder {
    fn default() -> Self {
        Self::create_empty()
    }
}