Allow to index files with null or boolean

This commit is contained in:
Quentin de Quelen 2019-12-12 19:04:10 +01:00
parent 1ea29bb92e
commit 3a4130f344

View File

@ -24,9 +24,7 @@ impl<'a> ser::Serializer for Indexer<'a> {
type SerializeStructVariant = ser::Impossible<Self::Ok, Self::Error>; type SerializeStructVariant = ser::Impossible<Self::Ok, Self::Error>;
fn serialize_bool(self, _value: bool) -> Result<Self::Ok, Self::Error> { fn serialize_bool(self, _value: bool) -> Result<Self::Ok, Self::Error> {
Err(SerializerError::UnindexableType { Ok(None)
type_name: "boolean",
})
} }
fn serialize_char(self, value: char) -> Result<Self::Ok, Self::Error> { fn serialize_char(self, value: char) -> Result<Self::Ok, Self::Error> {
@ -96,9 +94,7 @@ impl<'a> ser::Serializer for Indexer<'a> {
} }
fn serialize_none(self) -> Result<Self::Ok, Self::Error> { fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
Err(SerializerError::UnindexableType { Ok(None)
type_name: "Option",
})
} }
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error> fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
@ -113,13 +109,11 @@ impl<'a> ser::Serializer for Indexer<'a> {
} }
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> { fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
Err(SerializerError::UnindexableType { type_name: "()" }) Ok(None)
} }
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> { fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {
Err(SerializerError::UnindexableType { Ok(None)
type_name: "unit struct",
})
} }
fn serialize_unit_variant( fn serialize_unit_variant(
@ -128,9 +122,7 @@ impl<'a> ser::Serializer for Indexer<'a> {
_variant_index: u32, _variant_index: u32,
_variant: &'static str, _variant: &'static str,
) -> Result<Self::Ok, Self::Error> { ) -> Result<Self::Ok, Self::Error> {
Err(SerializerError::UnindexableType { Ok(None)
type_name: "unit variant",
})
} }
fn serialize_newtype_struct<T: ?Sized>( fn serialize_newtype_struct<T: ?Sized>(
@ -219,9 +211,14 @@ impl<'a> ser::Serializer for Indexer<'a> {
_name: &'static str, _name: &'static str,
_len: usize, _len: usize,
) -> Result<Self::SerializeStruct, Self::Error> { ) -> Result<Self::SerializeStruct, Self::Error> {
Err(SerializerError::UnindexableType { let indexer = StructIndexer {
type_name: "struct", attribute: self.attribute,
}) document_id: self.document_id,
indexer: self.indexer,
texts: Vec::new(),
};
Ok(indexer)
} }
fn serialize_struct_variant( fn serialize_struct_variant(