From 63e1fb4f96b31024b595efbed89ba6620a747323 Mon Sep 17 00:00:00 2001 From: Phillip Davis Date: Mon, 4 Jul 2022 21:49:40 -0400 Subject: [PATCH] Run the code formatter --- meilisearch-auth/src/action.rs | 6 +- meilisearch-auth/src/store.rs | 123 +++++++++++++++------------------ 2 files changed, 60 insertions(+), 69 deletions(-) diff --git a/meilisearch-auth/src/action.rs b/meilisearch-auth/src/action.rs index 127fb8e1a..cecc919aa 100644 --- a/meilisearch-auth/src/action.rs +++ b/meilisearch-auth/src/action.rs @@ -17,7 +17,7 @@ pub enum Action { #[serde(rename = "documents.delete")] DocumentsDelete = actions::DOCUMENTS_DELETE, #[serde(rename = "indexes.*")] - IndexAll = actions::INDEXES_ALL, + IndexesAll = actions::INDEXES_ALL, #[serde(rename = "indexes.create")] IndexesAdd = actions::INDEXES_CREATE, #[serde(rename = "indexes.get")] @@ -66,7 +66,7 @@ impl Action { DOCUMENTS_ADD => Some(Self::DocumentsAdd), DOCUMENTS_GET => Some(Self::DocumentsGet), DOCUMENTS_DELETE => Some(Self::DocumentsDelete), - INDEXES_ALL => Some(Self::IndexAll), + INDEXES_ALL => Some(Self::IndexesAll), INDEXES_CREATE => Some(Self::IndexesAdd), INDEXES_GET => Some(Self::IndexesGet), INDEXES_UPDATE => Some(Self::IndexesUpdate), @@ -98,7 +98,7 @@ impl Action { Self::DocumentsAdd => DOCUMENTS_ADD, Self::DocumentsGet => DOCUMENTS_GET, Self::DocumentsDelete => DOCUMENTS_DELETE, - Self::IndexAll => INDEXES_ALL, + Self::IndexesAll => INDEXES_ALL, Self::IndexesAdd => INDEXES_CREATE, Self::IndexesGet => INDEXES_GET, Self::IndexesUpdate => INDEXES_UPDATE, diff --git a/meilisearch-auth/src/store.rs b/meilisearch-auth/src/store.rs index 13515ca7c..06bb87275 100644 --- a/meilisearch-auth/src/store.rs +++ b/meilisearch-auth/src/store.rs @@ -92,77 +92,68 @@ impl HeedAuthStore { Action::into_enum_iter().collect() } else if key.actions.contains(&Action::DocumentsAll) { // if key.actions.contains.DocumentsAll add all actions related to documents. - key.actions.iter() - .cloned() - .filter(|action|{ // Prevents duplicate entries in the actions vector - *action != Action::DocumentsAdd && - *action != Action::DocumentsDelete && - *action != Action::DocumentsGet - }) - .chain(vec![ - Action::DocumentsAdd, - Action::DocumentsDelete, - Action::DocumentsGet - ]) - .collect() + key.actions + .iter() + .cloned() + .filter(|action| { + // Prevents duplicate entries in the actions vector + *action != Action::DocumentsAdd + && *action != Action::DocumentsDelete + && *action != Action::DocumentsGet + }) + .chain(vec![ + Action::DocumentsAdd, + Action::DocumentsDelete, + Action::DocumentsGet, + ]) + .collect() } else if key.actions.contains(&Action::IndexesAll) { - key.actions.iter() - .cloned() - .filter(|action|{ - *action != Action::IndexesAdd && - *action != Action::IndexesGet && - *action != Action::IndexesDelete && - *action != Action::IndexesUpdate - }) - .chain(vec![ - Action::IndexesAdd, - Action::IndexesGet, - Action::IndexesDelete, - Action::IndexesUpdate - ]) - .collect() + key.actions + .iter() + .cloned() + .filter(|action| { + *action != Action::IndexesAdd + && *action != Action::IndexesGet + && *action != Action::IndexesDelete + && *action != Action::IndexesUpdate + }) + .chain(vec![ + Action::IndexesAdd, + Action::IndexesGet, + Action::IndexesDelete, + Action::IndexesUpdate, + ]) + .collect() } else if key.actions.contains(&Action::SettingsAll) { - key.actions.iter() - .cloned() - .filter(|action|{ - *action != Action::SettingsGet && - *action != Action::SettingsUpdate - }) - .chain(vec![ - Action::SettingsGet, - Action::SettingsUpdate - ]) - .collect() + key.actions + .iter() + .cloned() + .filter(|action| { + *action != Action::SettingsGet && *action != Action::SettingsUpdate + }) + .chain(vec![Action::SettingsGet, Action::SettingsUpdate]) + .collect() } else if key.actions.contains(&Action::TasksAll) { - key.actions.iter() - .cloned() - .filter(|action|{ - *action != Action::TasksGet - }) - .chain(vec![ - Action::TasksGet - ]) - .collect() + key.actions + .iter() + .cloned() + .filter(|action| *action != Action::TasksGet) + .chain(vec![Action::TasksGet]) + .collect() } else if key.actions.contains(&Action::DumpsAll) { - key.actions.iter() - .cloned() - .filter(|action|{ - *action != Action::DumpsCreate - }) - .chain(vec![ - Action::DumpsCreate - ]) - .collect() + key.actions + .iter() + .cloned() + .filter(|action| *action != Action::DumpsCreate) + .chain(vec![Action::DumpsCreate]) + .collect() } else if key.actions.contains(&Action::StatsAll) { - key.actions.iter() - .cloned() - .filter(|action|{ - *action != Action::StatsGet - }) - .chain(vec![ - Action::StatsGet - ]) - .collect() + key.actions + .iter() + .cloned() + .filter(|action| *action != Action::StatsGet) + .chain(vec![Action::StatsGet]) + .collect() } else { key.actions.clone() };