qdrant_client/builders/
with_lookup_builder.rsuse crate::grpc_macros::convert_option;
use crate::qdrant::*;
pub struct WithLookupBuilder {
pub(crate) collection: Option<String>,
with_payload: Option<with_payload_selector::SelectorOptions>,
with_vectors: Option<with_vectors_selector::SelectorOptions>,
}
impl WithLookupBuilder {
#[allow(unused_mut)]
pub fn collection(self, value: String) -> Self {
let mut new = self;
new.collection = Option::Some(value);
new
}
#[allow(unused_mut)]
pub fn with_payload<VALUE: core::convert::Into<with_payload_selector::SelectorOptions>>(
self,
value: VALUE,
) -> Self {
let mut new = self;
new.with_payload = Option::Some(value.into());
new
}
#[allow(unused_mut)]
pub fn with_vectors<VALUE: core::convert::Into<with_vectors_selector::SelectorOptions>>(
self,
value: VALUE,
) -> Self {
let mut new = self;
new.with_vectors = Option::Some(value.into());
new
}
fn build_inner(self) -> Result<WithLookup, WithLookupBuilderError> {
Ok(WithLookup {
collection: match self.collection {
Some(value) => value,
None => {
return Result::Err(core::convert::Into::into(
::derive_builder::UninitializedFieldError::from("collection"),
));
}
},
with_payload: { convert_option(&self.with_payload) },
with_vectors: { convert_option(&self.with_vectors) },
})
}
fn create_empty() -> Self {
Self {
collection: core::default::Default::default(),
with_payload: core::default::Default::default(),
with_vectors: core::default::Default::default(),
}
}
}
impl From<WithLookupBuilder> for WithLookup {
fn from(value: WithLookupBuilder) -> Self {
value.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to convert {0} to {1}",
"WithLookupBuilder", "WithLookup"
)
})
}
}
impl WithLookupBuilder {
pub fn build(self) -> WithLookup {
self.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to build {0} into {1}",
"WithLookupBuilder", "WithLookup"
)
})
}
}
impl WithLookupBuilder {
pub(crate) fn empty() -> Self {
Self::create_empty()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum WithLookupBuilderError {
UninitializedField(&'static str),
ValidationError(String),
}
impl std::fmt::Display for WithLookupBuilderError {
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 WithLookupBuilderError {}
impl From<derive_builder::UninitializedFieldError> for WithLookupBuilderError {
fn from(error: derive_builder::UninitializedFieldError) -> Self {
Self::UninitializedField(error.field_name())
}
}
impl From<String> for WithLookupBuilderError {
fn from(error: String) -> Self {
Self::ValidationError(error)
}
}