use crate::grpc_macros::convert_option;
use crate::qdrant::*;
#[must_use]
#[derive(Clone)]
pub struct CreateVectorNameRequestBuilder {
pub(crate) collection_name: Option<String>,
pub(crate) wait: Option<Option<bool>>,
pub(crate) vector_name: Option<String>,
vector_config: Option<create_vector_name_request::VectorConfig>,
pub(crate) timeout: Option<Option<u64>>,
pub(crate) ordering: Option<Option<WriteOrdering>>,
}
impl CreateVectorNameRequestBuilder {
pub fn collection_name(self, value: impl Into<String>) -> Self {
let mut new = self;
new.collection_name = Option::Some(value.into());
new
}
pub fn wait(self, value: bool) -> Self {
let mut new = self;
new.wait = Option::Some(Option::Some(value));
new
}
pub fn vector_name(self, value: impl Into<String>) -> Self {
let mut new = self;
new.vector_name = Option::Some(value.into());
new
}
pub fn vector_config<VALUE: core::convert::Into<create_vector_name_request::VectorConfig>>(
self,
value: VALUE,
) -> Self {
let mut new = self;
new.vector_config = Option::Some(value.into());
new
}
pub fn timeout(self, value: u64) -> Self {
let mut new = self;
new.timeout = Option::Some(Option::Some(value));
new
}
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
}
fn build_inner(self) -> Result<CreateVectorNameRequest, CreateVectorNameRequestBuilderError> {
Ok(CreateVectorNameRequest {
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(),
vector_name: match self.vector_name {
Some(value) => value,
None => {
return Result::Err(core::convert::Into::into(
::derive_builder::UninitializedFieldError::from("vector_name"),
));
}
},
timeout: self.timeout.unwrap_or_default(),
ordering: self.ordering.unwrap_or_default(),
vector_config: { convert_option(&self.vector_config) },
})
}
fn create_empty() -> Self {
Self {
collection_name: core::default::Default::default(),
wait: core::default::Default::default(),
vector_name: core::default::Default::default(),
vector_config: core::default::Default::default(),
timeout: core::default::Default::default(),
ordering: core::default::Default::default(),
}
}
}
impl From<CreateVectorNameRequestBuilder> for CreateVectorNameRequest {
fn from(value: CreateVectorNameRequestBuilder) -> Self {
value.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to convert {0} to {1}",
"CreateVectorNameRequestBuilder", "CreateVectorNameRequest"
)
})
}
}
impl CreateVectorNameRequestBuilder {
pub fn build(self) -> CreateVectorNameRequest {
self.build_inner().unwrap_or_else(|_| {
panic!(
"Failed to build {0} into {1}",
"CreateVectorNameRequestBuilder", "CreateVectorNameRequest"
)
})
}
}
impl CreateVectorNameRequestBuilder {
pub(crate) fn empty() -> Self {
Self::create_empty()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum CreateVectorNameRequestBuilderError {
UninitializedField(&'static str),
ValidationError(String),
}
impl std::fmt::Display for CreateVectorNameRequestBuilderError {
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 CreateVectorNameRequestBuilderError {}
impl From<derive_builder::UninitializedFieldError> for CreateVectorNameRequestBuilderError {
fn from(error: derive_builder::UninitializedFieldError) -> Self {
Self::UninitializedField(error.field_name())
}
}
impl From<String> for CreateVectorNameRequestBuilderError {
fn from(error: String) -> Self {
Self::ValidationError(error)
}
}