optional feature for source
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dmitry Belyaev 2023-08-05 23:26:45 +03:00
parent abcb7d6dc2
commit 0c0a4e31ba
4 changed files with 61 additions and 51 deletions

View File

@ -14,7 +14,7 @@ name = "db_bench"
harness = false
[dependencies]
chgk_ledb_lib = {path = "../lib", features = ["sync"]}
chgk_ledb_lib = {path = "../lib", features = ["sync", "source"]}
serde_json="1.0"
zip="0.6"
rand="0.8"

View File

@ -13,13 +13,14 @@ description = "Библиотека для доступа к файлу базы
default = ["async"]
sync = ["zstd", "memmap"]
async = ["futures", "futures-core", "futures-util", "fmmap", "tokio", "async-compression", "async-stream"]
source = ["zip"]
[dependencies]
serde="1.0"
serde_derive="1.0"
serde_json="1.0"
bincode = "^2.0.0-rc.2"
zip="0.6"
zip= {version = "0.6", optional = true}
fmmap = { version = "0.3", features = ["tokio-async"] , optional = true}
tokio = { version = "1", features = ["fs","io-util","rt", "macros"] , optional = true}
futures-core = {version = "0.3", optional = true}

View File

@ -3,4 +3,5 @@ pub mod async_db;
#[cfg(feature = "sync")]
pub mod db;
pub mod questions;
#[cfg(feature = "source")]
pub mod source;

View File

@ -1,7 +1,5 @@
use serde_derive::{Deserialize, Serialize};
use crate::source::{SourceQuestion, SourceQuestionsBatch};
macro_rules! make {
($Target:ident; by {$($field:ident),+}; from $src:expr) => {$Target {$(
$field: $src.$field
@ -80,6 +78,12 @@ pub struct Question {
pub batch_info: BatchInfo,
}
#[cfg(feature = "source")]
pub mod convert {
use crate::source::{SourceQuestion, SourceQuestionsBatch};
use super::{BatchInfo, Question};
impl From<SourceQuestion> for Question {
fn from(src: SourceQuestion) -> Self {
make! {Self; with defaults and by {
@ -134,3 +138,7 @@ where
Box::new(iter)
}
}
}
#[cfg(feature = "source")]
pub use convert::QuestionsConverter;