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