qdrant_client/builders/
integer_index_params_builder.rsuse crate::qdrant::*;
pub struct IntegerIndexParamsBuilder {
pub(crate) lookup: Option<Option<bool>>,
pub(crate) range: Option<Option<bool>>,
pub(crate) is_principal: Option<Option<bool>>,
pub(crate) on_disk: Option<Option<bool>>,
}
impl IntegerIndexParamsBuilder {
pub fn new(lookup: bool, range: bool) -> Self {
Self::create_empty().lookup(lookup).range(range)
}
#[allow(unused_mut)]
pub fn lookup<VALUE: core::convert::Into<bool>>(self, value: VALUE) -> Self {
let mut new = self;
new.lookup = Option::Some(Option::Some(value.into()));
new
}
#[allow(unused_mut)]
pub fn range<VALUE: core::convert::Into<bool>>(self, value: VALUE) -> Self {
let mut new = self;
new.range = Option::Some(Option::Some(value.into()));
new
}
#[allow(unused_mut)]
pub fn is_principal(self, value: bool) -> Self {
let mut new = self;
new.is_principal = Option::Some(Option::Some(value));
new
}
#[allow(unused_mut)]
pub fn on_disk(self, value: bool) -> Self {
let mut new = self;
new.on_disk = Option::Some(Option::Some(value));
new
}
fn build_inner(self) -> Result<IntegerIndexParams, IntegerIndexParamsBuilderError> {
Ok(IntegerIndexParams {
lookup: self.lookup.unwrap_or_default(),
range: self.range.unwrap_or_default(),
is_principal: self.is_principal.unwrap_or_default(),
on_disk: self.on_disk.unwrap_or_default(),
})
}
fn create_empty() -> Self {
Self {
lookup: core::default::Default::default(),
range: core::default::Default::default(),
is_principal: core::default::Default::default(),
on_disk: core::default::Default::default(),
}
}
}
impl From<IntegerIndexParamsBuilder> for IntegerIndexParams {
fn from(value: IntegerIndexParamsBuilder) -> Self {
value.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to convert {0} to {1}",
"IntegerIndexParamsBuilder", "IntegerIndexParams"
)
})
}
}
impl IntegerIndexParamsBuilder {
pub fn build(self) -> IntegerIndexParams {
self.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to build {0} into {1}",
"IntegerIndexParamsBuilder", "IntegerIndexParams"
)
})
}
}
impl Default for IntegerIndexParamsBuilder {
fn default() -> Self {
Self::create_empty()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum IntegerIndexParamsBuilderError {
UninitializedField(&'static str),
ValidationError(String),
}
impl std::fmt::Display for IntegerIndexParamsBuilderError {
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 IntegerIndexParamsBuilderError {}
impl From<derive_builder::UninitializedFieldError> for IntegerIndexParamsBuilderError {
fn from(error: derive_builder::UninitializedFieldError) -> Self {
Self::UninitializedField(error.field_name())
}
}
impl From<String> for IntegerIndexParamsBuilderError {
fn from(error: String) -> Self {
Self::ValidationError(error)
}
}