mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
Add Serialize impl
This commit is contained in:
parent
75969f9f68
commit
6688604a93
@ -105,7 +105,7 @@ impl HeedAuthStore {
|
||||
|
||||
let mut actions = HashSet::new();
|
||||
for action in &key.actions {
|
||||
match action {
|
||||
match *action {
|
||||
Action::All => actions.extend(enum_iterator::all::<Action>()),
|
||||
Action::DocumentsAll => {
|
||||
actions.extend(
|
||||
|
@ -4,8 +4,9 @@ use std::str::FromStr;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use deserr::{take_cf_content, DeserializeError, Deserr, MergeWithError, ValuePointerRef};
|
||||
use enum_iterator::Sequence;
|
||||
use milli::update::Setting;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use time::format_description::well_known::Rfc3339;
|
||||
use time::macros::{format_description, time};
|
||||
use time::{Date, OffsetDateTime, PrimitiveDateTime};
|
||||
@ -180,7 +181,7 @@ fn parse_expiration_date(
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
#[derive(Copy, Clone, Serialize, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||
#[repr(transparent)]
|
||||
pub struct Action: u8 {
|
||||
const All = 0;
|
||||
@ -361,6 +362,20 @@ impl<'de> Deserialize<'de> for Action {
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Action {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
Self::SERIALIZATION_MAP
|
||||
.iter()
|
||||
.find(|(_, action)| self == action)
|
||||
.map(|(serialized, _)| serializer.serialize_str(serialized))
|
||||
// should always be found, so unwrap is safe to use
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
pub mod actions {
|
||||
use super::Action as A;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user