qdrant_client/builders/
count_points_builder.rsuse crate::grpc_macros::convert_option;
use crate::qdrant::*;
pub struct CountPointsBuilder {
pub(crate) collection_name: Option<String>,
pub(crate) filter: Option<Option<Filter>>,
pub(crate) exact: Option<Option<bool>>,
read_consistency: Option<read_consistency::Value>,
pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
pub(crate) timeout: Option<Option<u64>>,
}
impl CountPointsBuilder {
#[allow(unused_mut)]
pub fn collection_name(self, value: String) -> Self {
let mut new = self;
new.collection_name = Option::Some(value);
new
}
#[allow(unused_mut)]
pub fn filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
let mut new = self;
new.filter = Option::Some(Option::Some(value.into()));
new
}
#[allow(unused_mut)]
pub fn exact(self, value: bool) -> Self {
let mut new = self;
new.exact = Option::Some(Option::Some(value));
new
}
#[allow(unused_mut)]
pub fn read_consistency<VALUE: core::convert::Into<read_consistency::Value>>(
self,
value: VALUE,
) -> Self {
let mut new = self;
new.read_consistency = Option::Some(value.into());
new
}
#[allow(unused_mut)]
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
}
#[allow(unused_mut)]
pub fn timeout(self, value: u64) -> Self {
let mut new = self;
new.timeout = Option::Some(Option::Some(value));
new
}
fn build_inner(self) -> Result<CountPoints, CountPointsBuilderError> {
Ok(CountPoints {
collection_name: match self.collection_name {
Some(value) => value,
None => {
return Result::Err(core::convert::Into::into(
::derive_builder::UninitializedFieldError::from("collection_name"),
));
}
},
filter: self.filter.unwrap_or_default(),
exact: self.exact.unwrap_or_default(),
read_consistency: { convert_option(&self.read_consistency) },
shard_key_selector: self.shard_key_selector.unwrap_or_default(),
timeout: self.timeout.unwrap_or_default(),
})
}
fn create_empty() -> Self {
Self {
collection_name: core::default::Default::default(),
filter: core::default::Default::default(),
exact: core::default::Default::default(),
read_consistency: core::default::Default::default(),
shard_key_selector: core::default::Default::default(),
timeout: core::default::Default::default(),
}
}
}
impl From<CountPointsBuilder> for CountPoints {
fn from(value: CountPointsBuilder) -> Self {
value.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to convert {0} to {1}",
"CountPointsBuilder", "CountPoints"
)
})
}
}
impl CountPointsBuilder {
pub fn build(self) -> CountPoints {
self.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to build {0} into {1}",
"CountPointsBuilder", "CountPoints"
)
})
}
}
impl CountPointsBuilder {
pub(crate) fn empty() -> Self {
Self::create_empty()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum CountPointsBuilderError {
UninitializedField(&'static str),
ValidationError(String),
}
impl std::fmt::Display for CountPointsBuilderError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::UninitializedField(field) => {
write!(f, "`{}` must be initialized", field)
}
Self::ValidationError(error) => write!(f, "{}", error),
}
}
}
impl std::error::Error for CountPointsBuilderError {}
impl From<derive_builder::UninitializedFieldError> for CountPointsBuilderError {
fn from(error: derive_builder::UninitializedFieldError) -> Self {
Self::UninitializedField(error.field_name())
}
}
impl From<String> for CountPointsBuilderError {
fn from(error: String) -> Self {
Self::ValidationError(error)
}
}