use crate::util::ShouldSkip;
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct SuggestContextQuery {
context: String,
#[serde(default, skip_serializing_if = "ShouldSkip::should_skip")]
boost: Option<f32>,
#[serde(default, skip_serializing_if = "ShouldSkip::should_skip")]
prefix: Option<bool>,
}
impl SuggestContextQuery {
pub fn new<T>(context: T) -> Self
where
T: ToString,
{
Self {
context: context.to_string(),
boost: None,
prefix: None,
}
}
pub fn boost<T>(mut self, boost: T) -> Self
where
T: num_traits::AsPrimitive<f32>,
{
self.boost = Some(boost.as_());
self
}
pub fn prefix(mut self, prefix: bool) -> Self {
self.prefix = Some(prefix);
self
}
}
impl IntoIterator for SuggestContextQuery {
type IntoIter = std::option::IntoIter<Self::Item>;
type Item = Self;
fn into_iter(self) -> Self::IntoIter {
Some(self).into_iter()
}
}