qdrant_client/builders/
recommend_batch_points_builder.rsuse crate::grpc_macros::convert_option;
use crate::qdrant::*;
pub struct RecommendBatchPointsBuilder {
pub(crate) collection_name: Option<String>,
pub(crate) recommend_points: Option<Vec<RecommendPoints>>,
read_consistency: Option<read_consistency::Value>,
pub(crate) timeout: Option<Option<u64>>,
}
impl RecommendBatchPointsBuilder {
#[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 recommend_points(self, value: Vec<RecommendPoints>) -> Self {
let mut new = self;
new.recommend_points = 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 timeout(self, value: u64) -> Self {
let mut new = self;
new.timeout = Option::Some(Option::Some(value));
new
}
fn build_inner(self) -> Result<RecommendBatchPoints, RecommendBatchPointsBuilderError> {
Ok(RecommendBatchPoints {
collection_name: match self.collection_name {
Some(value) => value,
None => {
return Result::Err(core::convert::Into::into(
::derive_builder::UninitializedFieldError::from("collection_name"),
));
}
},
recommend_points: match self.recommend_points {
Some(value) => value,
None => {
return Result::Err(core::convert::Into::into(
::derive_builder::UninitializedFieldError::from("recommend_points"),
));
}
},
read_consistency: { convert_option(&self.read_consistency) },
timeout: self.timeout.unwrap_or_default(),
})
}
fn create_empty() -> Self {
Self {
collection_name: core::default::Default::default(),
recommend_points: core::default::Default::default(),
read_consistency: core::default::Default::default(),
timeout: core::default::Default::default(),
}
}
}
impl From<RecommendBatchPointsBuilder> for RecommendBatchPoints {
fn from(value: RecommendBatchPointsBuilder) -> Self {
value.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to convert {0} to {1}",
"RecommendBatchPointsBuilder", "RecommendBatchPoints"
)
})
}
}
impl RecommendBatchPointsBuilder {
pub fn build(self) -> RecommendBatchPoints {
self.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to build {0} into {1}",
"RecommendBatchPointsBuilder", "RecommendBatchPoints"
)
})
}
}
impl RecommendBatchPointsBuilder {
pub(crate) fn empty() -> Self {
Self::create_empty()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum RecommendBatchPointsBuilderError {
UninitializedField(&'static str),
ValidationError(String),
}
impl std::fmt::Display for RecommendBatchPointsBuilderError {
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 RecommendBatchPointsBuilderError {}
impl From<derive_builder::UninitializedFieldError> for RecommendBatchPointsBuilderError {
fn from(error: derive_builder::UninitializedFieldError) -> Self {
Self::UninitializedField(error.field_name())
}
}
impl From<String> for RecommendBatchPointsBuilderError {
fn from(error: String) -> Self {
Self::ValidationError(error)
}
}