mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
type setting struct
This commit is contained in:
parent
998d5ead34
commit
706643dfed
11 changed files with 47 additions and 29 deletions
|
@ -1,6 +1,7 @@
|
|||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::io;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use flate2::read::GzDecoder;
|
||||
use log::info;
|
||||
|
@ -10,10 +11,15 @@ use serde::{de::Deserializer, Deserialize, Serialize};
|
|||
use super::Index;
|
||||
use crate::index_controller::UpdateResult;
|
||||
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct Checked;
|
||||
#[derive(Clone, Default, Debug)]
|
||||
pub struct Unchecked;
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Settings {
|
||||
pub struct Settings<T> {
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_some",
|
||||
|
@ -49,21 +55,31 @@ pub struct Settings {
|
|||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub distinct_attribute: Option<Option<String>>,
|
||||
|
||||
#[serde(skip)]
|
||||
pub _kind: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn cleared() -> Self {
|
||||
Self {
|
||||
impl Settings<Checked> {
|
||||
pub fn cleared() -> Settings<Checked> {
|
||||
Settings {
|
||||
displayed_attributes: Some(None),
|
||||
searchable_attributes: Some(None),
|
||||
attributes_for_faceting: Some(None),
|
||||
ranking_rules: Some(None),
|
||||
stop_words: Some(None),
|
||||
distinct_attribute: Some(None),
|
||||
_kind: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Settings<Unchecked> {
|
||||
pub fn check(self) -> Settings<Checked> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -137,7 +153,7 @@ impl Index {
|
|||
|
||||
pub fn update_settings(
|
||||
&self,
|
||||
settings: &Settings,
|
||||
settings: &Settings<Checked>,
|
||||
update_builder: UpdateBuilder,
|
||||
) -> anyhow::Result<UpdateResult> {
|
||||
// We must use the write transaction of the update here.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue