mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
bump enum-iter and fix a bunch of error messages
This commit is contained in:
parent
bea81ae37b
commit
d1a6fb2971
394
Cargo.lock
generated
394
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@ version = "0.29.1"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
enum-iterator = "1.1.2"
|
enum-iterator = "1.1.3"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
meilisearch-types = { path = "../meilisearch-types" }
|
meilisearch-types = { path = "../meilisearch-types" }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use meilisearch_types::error::{Code, ErrorCode};
|
use meilisearch_types::error::{Code, ErrorCode};
|
||||||
use meilisearch_types::{internal_error, keys, milli};
|
use meilisearch_types::{internal_error, keys};
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, AuthControllerError>;
|
pub type Result<T> = std::result::Result<T, AuthControllerError>;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ use hmac::{Hmac, Mac};
|
|||||||
use meilisearch_types::keys::KeyId;
|
use meilisearch_types::keys::KeyId;
|
||||||
use meilisearch_types::milli;
|
use meilisearch_types::milli;
|
||||||
use meilisearch_types::star_or::StarOr;
|
use meilisearch_types::star_or::StarOr;
|
||||||
use meilisearch_types::milli;
|
|
||||||
use milli::heed::types::{ByteSlice, DecodeIgnore, SerdeJson};
|
use milli::heed::types::{ByteSlice, DecodeIgnore, SerdeJson};
|
||||||
use milli::heed::{Database, Env, EnvOpenOptions, RwTxn};
|
use milli::heed::{Database, Env, EnvOpenOptions, RwTxn};
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
@ -9,7 +9,7 @@ actix-web = { version = "4.2.1", default-features = false }
|
|||||||
csv = "1.1.6"
|
csv = "1.1.6"
|
||||||
either = { version = "1.6.1", features = ["serde"] }
|
either = { version = "1.6.1", features = ["serde"] }
|
||||||
milli = { git = "https://github.com/meilisearch/milli.git", branch = "indexation-abortion", default-features = false }
|
milli = { git = "https://github.com/meilisearch/milli.git", branch = "indexation-abortion", default-features = false }
|
||||||
enum-iterator = "0.7.0"
|
enum-iterator = "1.1.3"
|
||||||
fst = "0.4.7"
|
fst = "0.4.7"
|
||||||
proptest = { version = "1.0.0", optional = true }
|
proptest = { version = "1.0.0", optional = true }
|
||||||
proptest-derive = { version = "0.3.0", optional = true }
|
proptest-derive = { version = "0.3.0", optional = true }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::error::{Code, ErrorCode};
|
use crate::error::{Code, ErrorCode};
|
||||||
use crate::index_uid::IndexUid;
|
use crate::index_uid::IndexUid;
|
||||||
use crate::star_or::StarOr;
|
use crate::star_or::StarOr;
|
||||||
use enum_iterator::IntoEnumIterator;
|
use enum_iterator::Sequence;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{from_value, Value};
|
use serde_json::{from_value, Value};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
@ -197,7 +197,7 @@ fn parse_expiration_date(value: &Value) -> Result<Option<OffsetDateTime>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(IntoEnumIterator, Copy, Clone, Serialize, Deserialize, Debug, Eq, PartialEq, Hash)]
|
#[derive(Copy, Clone, Serialize, Deserialize, Debug, Eq, PartialEq, Hash, Sequence)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
#[serde(rename = "*")]
|
#[serde(rename = "*")]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use enum_iterator::Sequence;
|
||||||
use milli::update::IndexDocumentsMethod;
|
use milli::update::IndexDocumentsMethod;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use serde::{Deserialize, Serialize, Serializer};
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
@ -263,7 +264,7 @@ impl From<&KindWithContent> for Option<Details> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Sequence)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
Enqueued,
|
Enqueued,
|
||||||
@ -286,21 +287,32 @@ impl Display for Status {
|
|||||||
impl FromStr for Status {
|
impl FromStr for Status {
|
||||||
type Err = ResponseError;
|
type Err = ResponseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(status: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
if status.eq_ignore_ascii_case("enqueued") {
|
||||||
"enqueued" => Ok(Status::Enqueued),
|
Ok(Status::Enqueued)
|
||||||
"processing" => Ok(Status::Processing),
|
} else if status.eq_ignore_ascii_case("processing") {
|
||||||
"succeeded" => Ok(Status::Succeeded),
|
Ok(Status::Processing)
|
||||||
"failed" => Ok(Status::Failed),
|
} else if status.eq_ignore_ascii_case("succeeded") {
|
||||||
s => Err(ResponseError::from_msg(
|
Ok(Status::Succeeded)
|
||||||
format!("`{}` is not a status. Available types are", s),
|
} else if status.eq_ignore_ascii_case("failed") {
|
||||||
|
Ok(Status::Failed)
|
||||||
|
} else {
|
||||||
|
Err(ResponseError::from_msg(
|
||||||
|
format!(
|
||||||
|
"`{}` is not a status. Available status are {}.",
|
||||||
|
status,
|
||||||
|
enum_iterator::all::<Status>()
|
||||||
|
.map(|s| format!("`{s}`"))
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ")
|
||||||
|
),
|
||||||
Code::BadRequest,
|
Code::BadRequest,
|
||||||
)),
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Sequence)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum Kind {
|
pub enum Kind {
|
||||||
DocumentImport,
|
DocumentImport,
|
||||||
@ -320,25 +332,37 @@ pub enum Kind {
|
|||||||
impl FromStr for Kind {
|
impl FromStr for Kind {
|
||||||
type Err = ResponseError;
|
type Err = ResponseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(kind: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
if kind.eq_ignore_ascii_case("indexCreation") {
|
||||||
"document_addition" => Ok(Kind::DocumentImport),
|
Ok(Kind::IndexCreation)
|
||||||
"document_update" => Ok(Kind::DocumentImport),
|
} else if kind.eq_ignore_ascii_case("indexUpdate") {
|
||||||
"document_deletion" => Ok(Kind::DocumentDeletion),
|
Ok(Kind::IndexUpdate)
|
||||||
"document_clear" => Ok(Kind::DocumentClear),
|
} else if kind.eq_ignore_ascii_case("indexDeletion") {
|
||||||
"settings" => Ok(Kind::Settings),
|
Ok(Kind::IndexDeletion)
|
||||||
"index_creation" => Ok(Kind::IndexCreation),
|
} else if kind.eq_ignore_ascii_case("documentAdditionOrUpdate") {
|
||||||
"index_deletion" => Ok(Kind::IndexDeletion),
|
Ok(Kind::DocumentImport)
|
||||||
"index_update" => Ok(Kind::IndexUpdate),
|
} else if kind.eq_ignore_ascii_case("documentDeletion") {
|
||||||
"index_swap" => Ok(Kind::IndexSwap),
|
Ok(Kind::DocumentDeletion)
|
||||||
"cancel_task" => Ok(Kind::CancelTask),
|
} else if kind.eq_ignore_ascii_case("settingsUpdate") {
|
||||||
"task_deletion" => Ok(Kind::TaskDeletion),
|
Ok(Kind::Settings)
|
||||||
"dump_export" => Ok(Kind::DumpExport),
|
} else if kind.eq_ignore_ascii_case("dumpCreation") {
|
||||||
"snapshot" => Ok(Kind::Snapshot),
|
Ok(Kind::DumpExport)
|
||||||
s => Err(ResponseError::from_msg(
|
} else {
|
||||||
format!("`{}` is not a type. Available status are ", s),
|
Err(ResponseError::from_msg(
|
||||||
|
format!(
|
||||||
|
"`{}` is not a type. Available types are {}.",
|
||||||
|
kind,
|
||||||
|
enum_iterator::all::<Kind>()
|
||||||
|
.map(|k| format!(
|
||||||
|
"`{}`",
|
||||||
|
// by default serde is going to insert `"` around the value.
|
||||||
|
serde_json::to_string(&k).unwrap().trim_matches('"')
|
||||||
|
))
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ")
|
||||||
|
),
|
||||||
Code::BadRequest,
|
Code::BadRequest,
|
||||||
)),
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user