diff --git a/dump/src/reader/compat/v5_to_v6.rs b/dump/src/reader/compat/v5_to_v6.rs index 237381414..51858450e 100644 --- a/dump/src/reader/compat/v5_to_v6.rs +++ b/dump/src/reader/compat/v5_to_v6.rs @@ -183,7 +183,7 @@ impl CompatV5ToV6 { .map(|index| match index { v5::StarOr::Star => v6::StarOr::Star, v5::StarOr::Other(uid) => { - v6::StarOr::Other(v6::IndexUid::new_unchecked(uid.as_str())) + v6::StarOr::Other(v6::IndexUidPattern::new_unchecked(uid.as_str())) } }) .collect(), diff --git a/dump/src/reader/v6/mod.rs b/dump/src/reader/v6/mod.rs index edf552452..77d7a52bc 100644 --- a/dump/src/reader/v6/mod.rs +++ b/dump/src/reader/v6/mod.rs @@ -35,7 +35,7 @@ pub type PaginationSettings = meilisearch_types::settings::PaginationSettings; // everything related to the api keys pub type Action = meilisearch_types::keys::Action; pub type StarOr = meilisearch_types::star_or::StarOr; -pub type IndexUid = meilisearch_types::index_uid::IndexUid; +pub type IndexUidPattern = meilisearch_types::index_uid_pattern::IndexUidPattern; // everything related to the errors pub type ResponseError = meilisearch_types::error::ResponseError; diff --git a/meilisearch-types/src/index_uid_pattern.rs b/meilisearch-types/src/index_uid_pattern.rs index 1f82e83db..8cb50fee9 100644 --- a/meilisearch-types/src/index_uid_pattern.rs +++ b/meilisearch-types/src/index_uid_pattern.rs @@ -10,11 +10,16 @@ use crate::index_uid::{IndexUid, IndexUidFormatError}; /// An index uid pattern is composed of only ascii alphanumeric characters, - and _, between 1 and 400 /// bytes long and optionally ending with a *. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "test-traits", derive(proptest_derive::Arbitrary))] pub struct IndexUidPattern( #[cfg_attr(feature = "test-traits", proptest(regex("[a-zA-Z0-9_-]{1,400}\\*?")))] String, ); impl IndexUidPattern { + pub fn new_unchecked(s: impl AsRef) -> Self { + Self(s.as_ref().to_string()) + } + /// Returns wether this index uid matches this index uid pattern. pub fn matches(&self, uid: &IndexUid) -> bool { self.matches_str(uid.as_str())