qdrant-client 1.17.0

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

#[derive(Clone)]
pub struct ClearPayloadPointsBuilder {
    /// name of the collection
    pub(crate) collection_name: Option<String>,
    /// Wait until the changes have been applied?
    pub(crate) wait: Option<Option<bool>>,
    /// Affected points
    points: Option<points_selector::PointsSelectorOneOf>,
    /// Write ordering guarantees
    pub(crate) ordering: Option<Option<WriteOrdering>>,
    /// Option for custom sharding to specify used shard keys
    pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
    /// Timeout for the request in seconds
    pub(crate) timeout: Option<Option<u64>>,
}

impl ClearPayloadPointsBuilder {
    /// name of the collection
    pub fn collection_name(self, value: String) -> Self {
        let mut new = self;
        new.collection_name = Option::Some(value);
        new
    }
    /// Wait until the changes have been applied?
    pub fn wait(self, value: bool) -> Self {
        let mut new = self;
        new.wait = Option::Some(Option::Some(value));
        new
    }
    /// Affected points
    pub fn points<VALUE: core::convert::Into<points_selector::PointsSelectorOneOf>>(
        self,
        value: VALUE,
    ) -> Self {
        let mut new = self;
        new.points = Option::Some(value.into());
        new
    }
    /// Write ordering guarantees
    pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
        let mut new = self;
        new.ordering = Option::Some(Option::Some(value.into()));
        new
    }
    /// Option for custom sharding to specify used shard keys
    pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
        self,
        value: VALUE,
    ) -> Self {
        let mut new = self;
        new.shard_key_selector = Option::Some(Option::Some(value.into()));
        new
    }
    /// Timeout for the request in seconds
    pub fn timeout(self, value: u64) -> Self {
        let mut new = self;
        new.timeout = Option::Some(Option::Some(value));
        new
    }

    fn build_inner(self) -> Result<ClearPayloadPoints, ClearPayloadPointsBuilderError> {
        Ok(ClearPayloadPoints {
            collection_name: match self.collection_name {
                Some(value) => value,
                None => {
                    return Result::Err(core::convert::Into::into(
                        ::derive_builder::UninitializedFieldError::from("collection_name"),
                    ));
                }
            },
            wait: self.wait.unwrap_or_default(),
            points: { convert_option(&self.points) },
            ordering: self.ordering.unwrap_or_default(),
            shard_key_selector: self.shard_key_selector.unwrap_or_default(),
            timeout: self.timeout.unwrap_or_default(),
        })
    }
    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
    fn create_empty() -> Self {
        Self {
            collection_name: core::default::Default::default(),
            wait: core::default::Default::default(),
            points: core::default::Default::default(),
            ordering: core::default::Default::default(),
            shard_key_selector: core::default::Default::default(),
            timeout: core::default::Default::default(),
        }
    }
}

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

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

impl ClearPayloadPointsBuilder {
    pub(crate) fn empty() -> Self {
        Self::create_empty()
    }
}
/// Error type for ClearPayloadPointsBuilder
#[non_exhaustive]
#[derive(Debug)]
pub enum ClearPayloadPointsBuilderError {
    /// Uninitialized field
    UninitializedField(&'static str),
    /// Custom validation error
    ValidationError(String),
}

impl std::fmt::Display for ClearPayloadPointsBuilderError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::UninitializedField(field) => {
                write!(f, "`{field}` must be initialized")
            }
            Self::ValidationError(error) => write!(f, "{error}"),
        }
    }
}

impl std::error::Error for ClearPayloadPointsBuilderError {}

impl From<derive_builder::UninitializedFieldError> for ClearPayloadPointsBuilderError {
    fn from(error: derive_builder::UninitializedFieldError) -> Self {
        Self::UninitializedField(error.field_name())
    }
}

impl From<String> for ClearPayloadPointsBuilderError {
    fn from(error: String) -> Self {
        Self::ValidationError(error)
    }
}