Make the serde and zerocopy meilidb-types dependencies optional

This commit is contained in:
Clément Renault 2019-11-17 12:30:39 +01:00
parent c9c3cfcee9
commit a76169042f
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
2 changed files with 20 additions and 19 deletions

View File

@ -4,6 +4,14 @@ version = "0.1.0"
authors = ["Clément Renault <renault.cle@gmail.com>"] authors = ["Clément Renault <renault.cle@gmail.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies.zerocopy]
serde = { version = "1.0.101", features = ["derive"] } version = "0.2.8"
zerocopy = "0.2.8" optional = true
[dependencies.serde]
version = "1.0.101"
features = ["derive"]
optional = true
[features]
default = ["serde", "zerocopy"]

View File

@ -1,24 +1,16 @@
use serde::{Deserialize, Serialize}; #[cfg(feature = "zerocopy")]
use zerocopy::{AsBytes, FromBytes}; use zerocopy::{AsBytes, FromBytes};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Represent an internally generated document unique identifier. /// Represent an internally generated document unique identifier.
/// ///
/// It is used to inform the database the document you want to deserialize. /// It is used to inform the database the document you want to deserialize.
/// Helpful for custom ranking. /// Helpful for custom ranking.
#[derive( #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
Debug, #[cfg_attr(feature = "zerocopy", derive(AsBytes, FromBytes))]
Copy, #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Clone,
Eq,
PartialEq,
PartialOrd,
Ord,
Hash,
Serialize,
Deserialize,
AsBytes,
FromBytes,
)]
#[repr(C)] #[repr(C)]
pub struct DocumentId(pub u64); pub struct DocumentId(pub u64);
@ -27,7 +19,8 @@ pub struct DocumentId(pub u64);
/// ///
/// This is stored in the map, generated at index time, /// This is stored in the map, generated at index time,
/// extracted and interpreted at search time. /// extracted and interpreted at search time.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, AsBytes, FromBytes)] #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "zerocopy", derive(AsBytes, FromBytes))]
#[repr(C)] #[repr(C)]
pub struct DocIndex { pub struct DocIndex {
/// The document identifier where the word was found. /// The document identifier where the word was found.