os_query_builder_rs/term/
ids.rs1use serde::Serialize;
2use crate::term::term_type::TermType;
3
4#[derive(Debug, Default, Clone, Serialize)]
5pub struct IDs {
6 values: Vec<TermType>,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 boost: Option<f64>,
9}
10
11impl IDs {
12 pub fn new() -> Self {
13 Self::default()
14 }
15
16 pub fn values<T, F>(self, values: F) -> Self
17 where T: Into<TermType>,
18 F: IntoIterator<Item=T>
19 {
20 Self {
21 values: values.into_iter().map(|x| x.into()).collect(),
22 ..self
23 }
24 }
25
26 pub fn boost<T:Into<f64> + Serialize>(self, boost: T) -> Self {
27 Self {
28 boost: Some(boost.into()),
29 ..self
30 }
31 }
32
33}